Skip to content

Instantly share code, notes, and snippets.

@prof3ssorSt3v3
Created July 22, 2017 20:08
Show Gist options
  • Save prof3ssorSt3v3/7e3ec1a1e574ad286c62cf2c40c2b0d7 to your computer and use it in GitHub Desktop.
Save prof3ssorSt3v3/7e3ec1a1e574ad286c62cf2c40c2b0d7 to your computer and use it in GitHub Desktop.
//String split and Array join methods
//converting Strings to Arrays and Arrays to Strings
//String to Array str.split();
//Array to String arr.join();
//
let sentence = "Hello my name is Inigo Montoya";
let words = sentence.split(" ").sort();
console.log(words);
let chars = sentence.split("");
//console.log(chars);
let hyphenated = words.join("-");
console.log(hyphenated);
let oneWord = words.join("");
console.log(oneWord);
let x = sentence.split(" ").sort().join(" ");
console.log(x);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment