-2

This doesn't work, when I remove "let" from big value (in the 3 times it appears), it works.Why is that?

      let x = prompt("Enter number");

      if (x > 5) {
        let y = prompt("Enter another number");
        let z = prompt("Enter another number");

        let big = y;

        if (y > z) {
          let big = y;
        } else if (z > y) {
          let big = z;
        }

        for (let i = 0; big > i; i++) {
          console.log("hello");
        }
      }

Yoan
  • 17
  • 4

1 Answers1

2

Each time you use the keyword let, it reinitializes the variable. ideally you would only use let the first time you create the variable.

dqhendricks
  • 19,030
  • 11
  • 50
  • 83