String methods toUpperCase

const checkBaggage = function(items){
  const baggage = items.toLowerCase();
  if (baggage.includes("knife") || baggage.includes("gun")){
    console.log("You are not allowed on board")
  }else{
    console.log("Welcome onboard");
  }
}
checkBaggage("I have a laptop, some Food and a pocket Knife")
checkBaggage("Socks and Camera")
checkBaggage("Got some snacks and a gun for protection");

please why is knife inside the code equal to Knife when called.

It isn’t equal. You make your string lower case. So the “knife” is equal to “knife”

1 Like

the second knife has K in capital

You made everything lower case.

1 Like

ooh i see now. i converted everything item that will be passed to lowercase. thank you