String includes in JavaScript
Level 294 keystrokes
Uses includes() to check if a string contains a specific substring.
JavaScript code
// Create a string variable1let str = "Hello World";// includes() returns true if the substring is found// "World" is in "Hello World", so it returns true2console.log(str.includes("World"));// "xyz" is not in the string, so it returns false3console.log(str.includes("xyz"));Output
true false
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this JavaScript code and how often they appear.
"× 6.× 4(× 4)× 4;× 3=× 1