Created
April 2, 2017 04:32
-
-
Save vacas/7cc7953d5a270b07f2e6cb4f80e0e9d1 to your computer and use it in GitHub Desktop.
Codetrotters Fellowsihp - Coding Challenge Interview 1. Goal: Make a function that takes 2 strings and determines if they are anagrams (made it for command line using node.js)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var prompt = require('prompt-sync')(); | |
function checkSpell(string1, string2) { | |
if (string1.toUpperCase().split("").sort().join("").trim() === string2.toUpperCase().split("").sort().join("").trim()) { | |
return "This is an anagram"; | |
} else { | |
// Just for humor's sake | |
return "In Trump's words: WRONG!"; | |
} | |
} | |
function start() { | |
console.log("The purpose of this program is to check if the words you give us are anagrams."); | |
var string1 = prompt("Give us the first word: "); | |
var string2 = prompt("Give us the second word: "); | |
console.log("Processing..."); | |
setTimeout(function(){ | |
console.log(checkSpell(string1, string2)); | |
}, 2000); | |
} | |
start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment