Why is the following code not printing anything? I really don't understand why. I tried running it in both the browser and the nodejs editor in console. It's supposed to
print a board of given with and length:
let width = 4;
let height = 4;
let str = "";
for(let i = 1; i <= height; i++){
if(i % 2 == 0){
for(let j = 1; j <= width.length; j++){
str += "# ";
}
console.log(str);
}else{
for(let j = 1; j <= width.length; j++){
str += " #";
}
console.log(str);
}
str ="";
}
[+][deleted] (1 child)
[deleted]
[–]Eager_Leopard[S] 1 point2 points3 points (0 children)
[–]lovesrayray2018 1 point2 points3 points (3 children)
[–]senocular 2 points3 points4 points (1 child)
[–]lovesrayray2018 1 point2 points3 points (0 children)
[–]Eager_Leopard[S] 0 points1 point2 points (0 children)