Created
July 22, 2017 20:08
-
-
Save prof3ssorSt3v3/7e3ec1a1e574ad286c62cf2c40c2b0d7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//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