Match string case sensitive value with array

Here is my code!!!
I have one input field And
One of the array
I’m matching Input field entered value with arrray’s list.
Prob : Unable to match capital value with array’s list.
e.g if user enter one10 value so this one should be match or if user enter ONE10 in capital letter then this value should be match too.

function myFunctiontwo(){
  var good = [
      "one10",
      "two10",
      "three10"
  ];
  var a = document.getElementById("code").value.split(' ');


  var foundPresent = a.some(elem => good.indexOf(elem) > -1);
  if(foundPresent === true){
    alert("correct");
      
  }else {
    alert("wrong");
      
  }
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title></title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
    

    <input name="code" id="code" placeholder="code" required>
    <button id="submit" id="sumbit" onclick="myFunctiontwo()">GO</button>
</body>
</html>

17 thoughts on “Match string case sensitive value with array”

Leave a Comment