Home > Software design >  Un-Ending Loop?
Un-Ending Loop?

Time:10-26

Whenever I run this snippet:

let longString = 0;
let fact = 6;
const lettersLeft = ["abcde"]
    const select = lettersLeft;
    let j = 1
    while (j <= fact, j=j 1) {
      longString  = select;
    }
    console.log(longString);

it crashes my app. I'm thinking it is trying to run indefinately, or it cannot read something. How do I fix this because this is very important to my code.

CodePudding user response:

With a little change to your while expression you can make it work:

let longString = 0;
let fact = 6;
const lettersLeft = ["abcde"],
  select = lettersLeft;
let j = 1;
while (j   <= fact)
  longString  = select;

console.log(longString);

  • Related