Dividing an input string into two strings.. JAVASCRIPT

This is a homework question that I couldn't solve, the coding I wrote keeps giving me an error.
Using the Scanner, input a string that contains a single exclamation mark.
Divide the input string into two strings, one before and the other after the
exclamation mark, and output them. Do not include the exclamation mark in
the output. For example, if the input string is one potato two potato !three,
then the output would be
one potato two potato
ahmet buyuknahirciAsked:
Who is Participating?
Julian HansenConnect With a Mentor Commented:
var str = "one potato two potato !three";
var newstr = str.split('!');

Open in new window

Julian HansenCommented:
Lookup the JavaScript function split().
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.