const gata = function(x, y) {
let numb = 1;
for (let count = 0; count < y; count++) {
numb *= x;
}
return numb;
};
console.log(gata (2,55));
-
var and let
let allows you to declare variables that are limited in scope to the block, statement, or expression on which it is used. This is unlike the var keyword, which defines a variable globally, or locally to an entire function regardless of block scope. -
Pure function.
A pure function is a specific kind of value-producing function that not only
has no side effects but also doesnât rely on side effects from other codeâfor
example, it doesnât read global bindings whose value might change. A pure
function has the pleasant property that, when called with the same arguments,
it always produces the same value (and doesnât do anything else). A call to
such a function can be substituted by its return value without changing the
meaning of the code.
Solution to the Recursion exercise
function isEven(wholenum) {
if (wholenum < 0) {
return (isEven(-wholenum))
}else if (wholenum == 0) {
return true;
}else if (wholenum == 1) {
return false;
}else {
return isEven(wholenum - 2)
}
}
console.log(isEven(50));
console.log(isEven(75));
console.log(isEven(-1))