Ad
Code
Diff
  • function sum(a,b) {
      return +a + +b; // Now works for strings
    }
    • function sum(a,b) {
    • return a+b; // wrong returning
    • return +a + +b; // Now works for strings
    • }
Code
Diff
  • const tab = (f, a, b, h) => Array.from({length:Math.ceil((b-a)/h)+1}, (v,i) => f(a+(i*h))).reduce((a,c) => a+=c,0)
    
    • const tab = (f, a, b, h) => {
    • let sum = 0;
    • for (let x = a; x <= b; x +=h){
    • sum += f(x); //Filippov Ilya
    • }
    • return sum
    • }
    • const tab = (f, a, b, h) => Array.from({length:Math.ceil((b-a)/h)+1}, (v,i) => f(a+(i*h))).reduce((a,c) => a+=c,0)