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

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
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"