DEV Community

Discussion on: How to get a particular word from a long string in Javascript

Collapse
 
jonrandy profile image
Jon Randy 🎖️ • Edited

☝ What he said. Although:

const newCity = city.split("/")[1]
Enter fullscreen mode Exit fullscreen mode

is slightly shorter, and arguably more readable.

Collapse
 
emmanuelthecoder profile image
Emmanuel Aiyenigba

I agree. Although my aim here was to try out slice() on strings.