There is a string, and you need to write an algorithm that checks whether there are two identical characters in the string.
var stt = 'ABC'; var i; var a; for(i = 0; i<stt.length;i++) { for(a = 1; a<stt.length; a++) { if(stt.charAt(i) == stt.charAt(a)) { console.log('true'); } } }
But the fact is that two of the same elements are compared and in fact, it looks like this
if(stt.charAt(1) == stt.charAt(1)) { console.log('true'); }