jeudi 6 août 2020

If must use const on the program, how to fix it?

I know const can't work inside if, but if I must use const for the program. How can I fix it ?

for (var i = 1; i < 3; i ++) {

if (i==0) {const studentid = 'king';}
if (i==1) {const studentid = 'hong';}
if (i==2) {const studentid = 'chen';}

console.log(i);
console.log(studentid);

}

Aucun commentaire:

Enregistrer un commentaire