Lab 10a - JavaScript Strings Functions Objectives Creating applications that use JavaScript strings to do...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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 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
Expert Answer:
Related Book For
International Management Managing Across Borders and Cultures Text and Cases
ISBN: 978-0134376042
9th edition
Authors: Helen Deresky
Posted Date:
Students also viewed these programming questions
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
Stock A has a standard deviation of 7%. Stock B has a standard deviation of 12%. The correlation coefficient between the two stocks' returns is 0.4071. What is the risk (standard deviation) for an...
-
Chocolat Inc. decides to examine the effect of using the dual-rate method for allocating truck costs to each roundtrip. At the start of 2017, the budgeted costs were: Variable cost per...
-
Use the Ratio Test to determine the convergence or divergence of the series. If the Ratio Test is inconclusive, determine the convergence or divergence of the series using other methods. 18 n=0...
-
The payroll disbursements were for two persons named Ciotty and Ciotti with the same first name and address. The interesting observation is that Ciotty is dated February 28, 2019, or after while...
-
N-Hexane is used to extract oil from soybeans. The solid residue from the extraction unit, which contains 0.78 kg liquid hexane/kg dry solids, is contacted in a dryer with nitrogen that enters at...
-
What are some ways to determine which database management system will work best for a given project? What are some best practices or industry-accepted criteria for matching a given database...
-
The Shop at Home Network sells various household goods during live television broadcasts. The company owns several warehouses to hold many of the goods it sells, but also leases extra warehouse space...
-
You have decided to save for a vacation home that you plan to buy 20 years from now. You have decided that you want to spend no more than $500,000 on the home, Assuming that you can earn an interest...
-
Can the concept of moral panics, as theorized by Cohen and others, help explain the process through which media, politicians, and moral entrepreneurs construct and amplify public anxieties about...
-
Margot bought a small residential rental building 15 years ago for $150,000. In the current year, she sold it for $400,000. She had taken $55,000 of straight-line depreciation. Margot is in the 35...
-
How do evolutionary psychology perspectives contribute to our understanding of the adaptive functions and evolutionary origins of gendered behaviors, roles, and preferences, and what are the...
-
How the contract and record keeping should be done by supervisor while assisting supervisor? Explain briefly
-
In reviewing an income statement, you notice an operating income of $52,500 and an income tax rate of 25% of income. If you are looking for the amount to report for income for financial accounting...
-
8) Indicate whether each of the following statements is True (T) or False (F). (1 pt each) The three major categories of the master budget are the operating budgets, the capital budgets, and the...
-
Avatar Financials, Inc., located on Madison Avenue, New York City, is a company that provides financial advice to individuals and small- to mid-sized businesses. Its primary operations are in wealth...
-
Describe the autocratic versus democratic leadership dimension. Discuss the cultural contingency in this dimension and give some examples of research findings indicating differences among countries.
-
Discuss the effects of various forms of technology on international business. What role does the Internet play? Where is this all leading? Explain the meaning of "appropriability of technology." What...
-
Discuss how you would develop a profile of an effective leader from the research results of the GLOBE project. Give an example.
-
For the Lyman series, what is the wavelength of the line with the second longest wavelength? Would it be visible to the human eye?
-
In 1924 French theorist Louis de Broglie (1892 1987, Nobel laureate in physics 1929) proposed that matter has a wavelike nature expressed by \(\lambda=\frac{h}{m v}\). Show that his relation agrees...
-
This problem presents an example of the Correspondence Principle. Suppose that the electron in hydrogen is traveling in a circular orbit with quantum number \(n\) and makes a transition to \(n+1\),...
Study smarter with the SolutionInn App