in
iterates an object's keys and shouldn't be used for arrays. Use of
instead.
let lines = ["Hi","Bye","Gone"];
let match = false;
for(let line of lines){
if(line === "Bye"){
match = true;
}
}
console.log(match);
It often helps to debug your code to see errors you're making. For that, you could have simply added debugger
, opened your console and see all the variable's values.
for(let line of lines){
debugger;
if(line === "Bye"){
match = true;
}
}
Also see How do I check whether an array contains a string in TypeScript? for more information on how this check is usually done