1

Below code enters the if clause below,

var title = "İnsanlar";
var keyword = "in";
title = title.toLowerCase();

if(title.indexOf(keyword) == -1)
{
  alert(title);
}

when I did some debugging, I realised that title.charCodeAt(1) returns 775 while keyword.charCodeAt(1) returns 110. Which causes my application's search functionality to be broken.

How can I fix this ?

HOY
  • 1,067
  • 10
  • 42
  • 85
  • Well, those are indeed different characters. i̇ !== i This might be something for RegEx – Jacob Mar 10 '19 at 03:26
  • maybe check if the characters coming in are actually letters? **const isChar = (input) => input.length === 1 && input.match(/[a-z]/i);** – Jacob Mar 10 '19 at 03:31

1 Answers1

0

I think there is issue of copy paste text.Don't copy paste value of variable write it down.See below.

https://js.do/code/293600

Rajan Kashiyani
  • 891
  • 7
  • 11
  • Actually in my language, İ and i are the same chacaters, but in computer terms, they are not. I is a different character, so this won't help. But thank you. – HOY Mar 10 '19 at 14:47