mardi 9 avril 2019

About my function, it's output doesn't show up and produces an error. How can I fix it?

I'm trying to take an output of my second function (isEven) but it doesn't work. and when I write the second function, the output of my first function disappears too.

document.write(fibonacciSQ(1,2) + "<br />");

function fibonacciSQ(first, second) {
  total = first + second;
  first = second;
  second = total;
  return total;
}

document.write(isEven(6));

function isEven(x) {
  if (x % 2 == 0) {
    document.write(x + " is even.");
  } else {
    document.write(x + " is not even.");
}

I expect it to output "6 is even." but it doesn't.

Aucun commentaire:

Enregistrer un commentaire