Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab 10a - JavaScript Strings Functions Objectives Creating applications that use JavaScript strings to do useful stuff What to do in Lab? M 1.

image

Lab 10a - JavaScript Strings Functions Objectives Creating applications that use JavaScript strings to do useful stuff What to do in Lab? M 1. Log in to the computer. If you are reading this, you must have done this already. 2. Create CPSC1045\Lab10a folder 3. 4. Download the file Lab10a.zip from D2L to your system. Unzip the contents into your Lab10a folder. Open the included HTML document named Lab10a.html in Google Chrome by either double clicking (if Chrome is the default browser) or by right clicking on it in your file explorer and then selecting Open With -> Google Chrome. The document looks as follows: Lab 10a - JavaScript Strings Functions The Task: A Calculator that Does Not Need an Operator Enter some numbers separated by a separator and I will sum them up. Enter your numbers here: Enter your separator here: Add My Numbers Output here Copyright Khurram Shehzad 2020 5. You don't need to edit the Lab10a.html file since it already contains all the tags you need to complete this lab. You will however need to create a JS file named Lab10a.js in which you can write your code and functions. com The Task (10 marks) 6. Write function named addNumbers () that takes a list of numbers (as a string) from the box labeled Enter your numbers here and a separator (such as a space character, a comma, a semicolon, colon etc) from the box labeled Enter your separator here. 7. The function detects the numbers in the string which are delimited by a separator. For example, if the string in the first input box is: 1 2 3 4 5 6 7 8 9 10 and the separator specified in the second input box is a whitespace, then the numbers are 1, 2, 3, 4 etc. Likewise, if the string in the first input box is: 1,2,3,4,5,6,7,8,9,10 and the separator specified in the second input box is a comma, then once again the numbers are 1, 2, 3, 4 etc. 8. While adding the numbers, the function keeps track of the running total in a variable sum which it returns in the end as part of a string as follows: The sum of the numbers is 55. Some sample runs of the application are as follows: Lab 10a - JavaScript Strings Functions The Task: A Calculator that Does Not Need an Operator Enter some numbers separated by a separator and I will sum them up. Enter your numbers here: 12345678910 The separator here is a whitespace Enter your separator here: Add My Numbers The sum of the numbers is 55. Copyright Khurram Shehzad 2020 s.com Lab 10a - JavaScript Strings Functions The Task: A Calculator that Does Not Need an Operator Page 2 of 3 Enter some numbers separated by a separator and I will sum them up. Enter your numbers here: 1,2,3,4,5,6,7,8,9,10 Enter your separator here:, The separator here is a comma Add My Numbers The sum of the numbers is 55. Copyright Khurram Shehzad 2020 Submission: What to hand in Zip the folder Lab10a which contains your source code (the file Lab10a.html and the Lab10a.js file you created) and upload it to D2L. Submission: When to hand in At the end of the lab period. Page 3 of 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Run ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

International Management Managing Across Borders and Cultures Text and Cases

Authors: Helen Deresky

9th edition

134376048, 978-0134376042

More Books

Students also viewed these Programming questions