Convert a string to an array

Lee·2022년 6월 20일

Algorithm

목록 보기
21/92
post-thumbnail

❓ Complementary DNA

Q. 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", "my", "favorite"]

✔ Solution

function stringToArray(string) {
  return string.split(" ");
}
profile
Lee

0개의 댓글