13 Function review: Does it suggest me to find new math rules?


#1

// Accepts a number x as input and returns its square
var square = function (x) {
return x * x;
};

// Write the function multiply below
// It should take two parameters and return the product

var multiply = function (z , y) {
if(z==0 || y==0){
return 0;
} else {
return z + y;
}
};

multiply(2 , 3);

it says
Oops, try again. Your function multiply failed on inputs 1,1 where you returned 2 instead of 1
how is it possible? 1+1=2, is it?


#2

We could consider multiplication as a form of addition, but then we need a repetitive process to perform the addition.

   4
+  4
+  4
+  4
+  4
= 20 == 5 * 4

You'll want your function to return z * y;