javascript get all characters before a certain one

Solutions on MaxInterview for javascript get all characters before a certain one by the best coders in the world

showing results for - "javascript get all characters before a certain one"
Serena
16 Apr 2020
1// say you wanted to collect all the chars before a slash (/).
2
3myString = "12345.67890";
4
5newString = myString.substring(0, myString.indexOf('/'));
6
7console.log(newString);
8
9// returns "12345"