Home > database >  Get all result not just the last one
Get all result not just the last one

Time:12-10

Hope you all are doing well. I have problem with for loop i want to get all result not just the last one.

for (var i = 1; i < 5; i  ) {
     var result = "";
     result  = i;
}
console.log(result)

Can you please help me to resolve it. Thanks <3

CodePudding user response:

try using let and move the result ="" outside loop

let result="";

for (let i = 1; i < 5; i  ) {
     result  = i;
}
console.log(result)
  • Related