Write a function splitInTwo () that takes a string as argument and then splits it according to the following: • If the string is longer than 10 characters, it is split in half and the two strings are returned in an array; • if the string is 10 characters or less, the function simply returns the original string in an array. Create an HTML5 document and place a text control into the document. Place your function into a JavaScript file that you link to the document. Place a button under the text control and script it to send the string currently in the text control to the function. Create a document division in the document below the button and write JavaScript in the file that will write the string(s) returned by the function into the document division, each on a new line. The image below shows the result of submitting a string to the function from the document. Hints: you might find that writing a function to call the split- InTwo () function and write the returned strings to the page, is better. Note that while there were two substring functions in JavaS- cript previously, there is now only one approved substring func- tion: String.substring() function. Also, look up Math.ceil() and Math.floor() - these functions may prove useful. Please enter any string into the text control below. qwertyuiopas Submit the string qwerty uiopas V

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter6: Arrays
Section: Chapter Questions
Problem 5GZ
icon
Related questions
Question
Write a function split InTwo () that takes a string as argument
and then splits it according to the following:
• If the string is longer than 10 characters, it is split in half and
the two strings are returned in an array;
• if the string is 10 characters or less, the function simply returns
the original string in an array.
Create an HTML5 document and place a text control into the
document. Place your function into a JavaScript file that you link to
the document. Place a button under the text control and script it to
send the string currently in the text control to the function. Create
a document division in the document below the button and write
JavaScript in the file that will write the string(s) returned by the
function into the document division, each on a new line.
The image below shows the result of submitting a string to the
function from the document.
Hints: you might find that writing a function to call the split-
InTwo () function and write the returned strings to the page, is
better. Note that while there were two substring functions in JavaS-
cript previously, there is now only one approved substring func-
tion: String.substring() function. Also, look
up Math.ceil() and Math.floor() - these functions may
prove useful.
Please enter any string into the text control below.
qwertyuiopas
Submit the string
qwerty
uiopas
V
End of document
O
X
Transcribed Image Text:Write a function split InTwo () that takes a string as argument and then splits it according to the following: • If the string is longer than 10 characters, it is split in half and the two strings are returned in an array; • if the string is 10 characters or less, the function simply returns the original string in an array. Create an HTML5 document and place a text control into the document. Place your function into a JavaScript file that you link to the document. Place a button under the text control and script it to send the string currently in the text control to the function. Create a document division in the document below the button and write JavaScript in the file that will write the string(s) returned by the function into the document division, each on a new line. The image below shows the result of submitting a string to the function from the document. Hints: you might find that writing a function to call the split- InTwo () function and write the returned strings to the page, is better. Note that while there were two substring functions in JavaS- cript previously, there is now only one approved substring func- tion: String.substring() function. Also, look up Math.ceil() and Math.floor() - these functions may prove useful. Please enter any string into the text control below. qwertyuiopas Submit the string qwerty uiopas V End of document O X
Expert Solution
steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning