+ 2

Appear only on the fourth iteration

How can I make 'congrets' appear only on the fourth iteration if(Object.keys(num1)[i].length === 4) { correction.innerHTML = congrets; } else if (Object.keys(num1).length[i] < 1) { correction.innerHTML = "1st string"; } else { correction.innerHTML = "2nd string"; } https://code.sololearn.com/WT6RNLRf51xp/?ref=app

14th Jan 2022, 12:46 AM
Steve Nova
Steve Nova - avatar
4 Antworten
+ 2
I see a potential error: you only have 1 equals operator in the if statement
14th Jan 2022, 12:54 AM
Moshe Schnitzler
Moshe Schnitzler - avatar
+ 2
try if(Object.keys(num1)[i].length === 4){ //your code goes here }
14th Jan 2022, 1:05 AM
Moshe Schnitzler
Moshe Schnitzler - avatar
+ 2
Oh my God. You guys are amazing. The code: if (i==3) { numcount.innerHTML = congrets; } works perfectly fine. It was really a lets go ahead and do this thing. This was really an innovation. Moshe Schnitzler, Shadoff, Dragon God thank you for your support and help I appreciate it. Thank you so much.
14th Jan 2022, 7:57 PM
Steve Nova
Steve Nova - avatar
+ 1
//if iteration begins from zero if (i==3){ //Your code } //if iteration begins from one if (i==4){ //Your code }
14th Jan 2022, 7:38 AM
Shadoff
Shadoff - avatar