Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Dividing an input string into two strings.. JAVASCRIPT

Posted on 2016-10-06
3
Medium Priority
?
72 Views
Last Modified: 2016-11-09
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
Comment
Question by:ahmet buyuknahirci
  • 2
3 Comments
 
LVL 60

Expert Comment

by:Julian Hansen
ID: 41832766
Lookup the JavaScript function split().
0
 
LVL 60

Accepted Solution

by:
Julian Hansen earned 2000 total points (awarded by participants)
ID: 41853427
var str = "one potato two potato !three";
var newstr = str.split('!');
console.log(newstr);

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question