Ad

Write a function that takes a string and returns it with spaces between every letter.

Example:

  "october" => "o c t o b e r"
function spaceMaker(str){

    return str.split("").join(" ");

}
Strings
Data Types

An anagram is the result of rearranging the letters of a word to produce a new one.

Write a function that takes a word and returns and array with all anagrams (all possible combinations of letter in a word).

###Example:

  allAnagrams("bu") == ["bu", "ub"]
function allAnagrams(word) {

	if (word.length < 2) {
		return [word];
	} else {
		var allAnswers = [];
		for(var i = 0; i < word.length; i++) {
			var letter = word[i];
		  var shorterWord = word.substr(0, i) + word.substr(i+1, word.length - 1);
		  var shortWordArray = allAnagrams(shorterWord);	
		  for (var j = 0; j < shortWordArray.length; j++) {
			  allAnswers.push(letter + shortWordArray[j]); 
		  }
		
   	}
	  return allAnswers;
	}
}