Quick actions

cmd+k|ctrl+k

Navigation

Languages

str to arr

Snippet info

Language

JavaScript

Visibility

public

Author

misbahul.munir0224

Created

2024-09-24T14:49:32.053239Z

Updated

2024-09-24T16:15:19.306912Z

/* console.log("Hello World!");Write a function to split a string and convert it into an array of words.

Examples (Input ==> Output):
"Robin Singh" ==> ["Robin", "Singh"]

"I love arrays they are my favorite" ==> ["I", "love", "arrays", "they", "are", "m */
// codewars 8kyu

// with function biasa
function myFunction(a) {
    return a.split(' ');
}

console.log(myFunction("I love arrays they are my favorite"))

// with arrow function
const myFunction = a => a.split(' ')

console.log(myFunction("I love arrays they are my favorite"))
INFO