JavaScript String Type

Includes

We can check whether a string contains another string by using the method includes. This method returns a Boolean value.

const title = "The Lies of Locke Lamora"
console.log(title.includes("Lies")) // true

Read more on MDN

String.prototype.includes()

Test yourself

Description

Define a new function with the name

isAmerican

that takes a string input parameter and checks whether the string contains

awesome

We do not care about the capitalization, and want it to return true for any combination of upper and lower case variations of the search word.

Tests

  1. 1 You should define a function named isAmerican.
  2. 2isAmerican("This super mediocre thing was awesome!") should return true.
  3. 3isAmerican("Awesome, let us do that!") should return true.
  4. 4isAmerican("That sounds aWeSOme!") should return true.
  5. 5isAmerican("Brilliant!") should return false.
  6. 6isAmerican("To us — richer and cleverer than everyone else!") should return false.
Editor