mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-11-13 06:23:00 +08:00
Changed the identations
This commit is contained in:
parent
672e2864a8
commit
5279eb2098
@ -1,21 +1,21 @@
|
|||||||
// TO CHECK IF TWO STRINGS ARE ANAGRAM OR NOT
|
// TO CHECK IF TWO STRINGS ARE ANAGRAM OR NOT
|
||||||
|
|
||||||
function anagram(word1, word2){
|
function anagram(word1, word2) {
|
||||||
var sorted1 = word1.split("").sort().join(""); //SORTING WORD1
|
let sorted1 = word1.split('').sort().join(''); //SORTING WORD1
|
||||||
var sorted2 = word2.split("").sort().join(""); //SORTING WORD2
|
let sorted2 = word2.split('').sort().join(''); //SORTING WORD2
|
||||||
|
|
||||||
//COMPARING LENGTH AND CHECKING ===
|
//COMPARING LENGTH AND CHECKING ===
|
||||||
if (sorted1.length == sorted2.length && sorted1 === sorted2) {
|
if (sorted1.length === sorted2.length && sorted1 === sorted2) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(anagram("binary", "brainy")){
|
if(anagram('binary', 'brainy')){
|
||||||
alert("AN ANAGRAM");
|
alert('AN ANAGRAM');
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
alert("NOT AN ANAGRAM");
|
alert('NOT AN ANAGRAM');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user