Here is the code snippet I am currently working on:
var var1 = 58;
for(var i=0;i<10;i++){
if(("var"+i) == 58) {
console.log("they are equal");
}
}
I am wondering why ("var" + i) is not equal to 58 in this scenario. Could someone please provide an explanation?
My understanding is that the first item is a variable while the second one is simply a string. Is there a method to have this code function as intended?
I realize this might seem like a basic question to some, but I am still at the early stages of learning to code. Any assistance would be greatly appreciated! :)