Skip to content

Instantly share code, notes, and snippets.

@vacas
Created April 2, 2017 04:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vacas/7cc7953d5a270b07f2e6cb4f80e0e9d1 to your computer and use it in GitHub Desktop.
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)
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