1

A user writes 'football' into my input bar and then the action on line 6 and 7 executes.
But I what if the user writes "Football", with a capital letter? I tried to implement the "logial or" || but I couldn't get it to work.

var input = document.getElementById("user_input");
let footballTeams = ["Manchester","Barcelona","Copenhagen"]

if (input.value == "football") {
    alert("These cities have football teams:" +
          "\n" + footballTeams[0] + "," + " " + footballTeams[1] + "," + " " + footballTeams[2])
Andreas
  • 21,535
  • 7
  • 47
  • 56

2 Answers2

1

try this:

if (input.value.toLowerCase() == "football")
-1

Try

if (input.value.toLowerCase() == "football") {
   console.log('inside if');
}
<input id=input value="Football">
Kamil Kiełczewski
  • 85,173
  • 29
  • 368
  • 345