Write a JavaScript function to test case insensitive string comparison.
NodeJS
console.log(compare_strings('abcd', 'AbcD'));
console.log(compare_strings('abcd', 'Abce'));
console.log(compare_strings('ABCD', 'ABCD'));
console.log(compare_strings('abcd', 'Abce'));
function compare_strings(str1,str2)
{
var temp = str1.split('');
var temp2 = str2.split('')
for(var i =0; i<temp.length ; i++)
{
if(temp[i] === temp2[i])
{
return true;
}
else
{
return false;
}
}
}
Output
Embed on website
To embed this program on your website, copy the following code and paste it into your website's HTML:
Comments
This comment belongs to a banned user and is only visible to admins.
This comment belongs to a deleted user and is only visible to admins.