On JavaScript split( ) and join ( ) methods

I finally grasped the difference between array methods Split and Join today

Both accept arguments

However, split( ) divides the string into array while join( ), adds the array back to a string

So how are they used?

Suppose you want to run an array method on a string. Something like filter( ) or map( )

There are three steps to make this work

1. Split the string first into arrays

2. Work the solution using the array methods

3. Then join back together as a string

Common syntax is:

someStr.split(" ") - divides this string into an array

someArr.join(" ") - joins the array together to a string



Koddess

Comments

Popular posts from this blog

Passion

Notions (Wi-Fi)

Took so long