+ 1
Label text in JavaScript
Okay one question is say you have an array like var this=[“burger”,”cucumber”] And you want to make and if statement that says if( this text is on the word burger) then how you do that
12 Respuestas
+ 2
var a=["burger","cucmber"]
for(i of a){
if(i=="burger" && i.search("u")){
console.log("u is in burger")
}
}
+ 1
Yes. Array of your 2nd post.
0
so do i need both in the if statement or can i just put the i==“burger”
0
You can do it however you like
0
okay its saying that for(i of a) is not a thing so do i put for(var i=0;i<5;i++) or something like that
0
for( let i of a)
if( i == "burger")
console.log(i);
Is this you are looking...?Imhoopin2 Aball
0
its telling me that a is not defined
0
yes you can even do
for(var i=0;i<2;i++){
if (a[i]=="burger"){
for(j=0;j<a[i].length;j++){
if (a[i][j]=="u"){
console.log('u in burger')
}
}
}
for(i of a )is actually a thing ,it iterates over every element in list and assign value to i
0
is a the array?
0
Obviously I have used "a" like you used "this" ,
0
oh okay😁