+ 1
How can I make this code work?
How can I make this code work? https://code.sololearn.com/W24i0AC0Wqgl/?ref=app
4 Answers
+ 3
صلاح الدين حلواني
You can even do without loop using includes function like this:
if(maincities.includes(city)) {
document.write("your city is from the main cities.")
} else {
document.write("your city is not from the main cities.")
}
+ 2
I use console.log and change for loop little bit, so now it check length of your maincities.
And add one more console lot to track how for loop work.
https://code.sololearn.com/W1NnuQHF9Sdz/?ref=app
+ 2
Your problem is exualy with using i+1 in for loop, so use i++.
i++ is exualy i = i + 1, so now you see where is problem, you never set this part
i =
You need to use i = i + any number, or if you add just one then you can use just i++
+ 1
Thank you Serbian.