Word to Array
Ande Caleb
Posted on July 26, 2022
a simple way to convert a String to an Array is by Spreading it... within the array brackets [ ... ] symbols, which is easier than using the String.prototype.split()
let str = 'Aminu Kano';
array = [ ...str ]; //break the array into letters.
This outputs an array of 10 elements. which becomes
[ "A", "m", "i", "n", "u", " ", "K", "a", "n", "o" ];
//same result can be achieved using the code below.
str.split("");
but the latter seems much easier and cleaner
hope this helps..
💖 💪 🙅 🚩
Ande Caleb
Posted on July 26, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
privacy Caught in the Crunch My Journey from Snacks to 2 Million Exposed Users Privacy
November 30, 2024
devchallenge Submission for the DevCycle Feature Flag Challenge: Feature Flag Funhouse
November 30, 2024