• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 89
  • Last Modified:

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
three
0
ahmet buyuknahirci
Asked:
ahmet buyuknahirci
  • 2
1 Solution
 
Julian HansenCommented:
Lookup the JavaScript function split().
0
 
Julian HansenCommented:
var str = "one potato two potato !three";
var newstr = str.split('!');
console.log(newstr);

Open in new window

0
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.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now