subject

You have successfully made a basic webpage calculator! Now that you’ve learned how to use HTML forms and write JavaScript functions, you are going to extend your calculator to include addition and subtraction. Log in to REPL. it and open your calculator program.
Using the web form that you’ve already created as your guide, add in two more buttons to your index. html file—one for addition and one for subtraction.
In your index. js file, create a function for addition and a function for subtraction. Make sure to call the functions correctly.
Test your new program. Did you get an incorrect value for the addition?
You may remember from Python that we sometimes have to convert strings to numbers in order to add them correctly. When you get the values from the text fields, they are automatically treated as strings. That’s not a problem for subtracting, multiplying, or dividing, but it is for addition because both strings get joined together. So, 3 + 5 becomes 35 instead of 8. To get around this, we’ll need to type cast the two variables to be integers using the built-in function parseInt() . Use parseInt() in this way:

num1 = parseInt(num1);

Code a similar line for num2 . Put both of them after you get their values from the text fields, and you should get a more correct result!

Add at least four CSS rules to your web form to make it look better. You might add in a background color, change the font size or style, change the color of the answer, or format the buttons. Check out this website for some ideas and tips on styling buttons:
https://www. w3schools. com/css/css3_buttons. asp
In order to change the style of the text fields, use the CSS selector input . To change the style of the buttons, use the CSS selector button . You could also give your calculator a fancy title—the sky’s the limit!
When you are finished, share the link to your webpage with your teacher by clicking on the share button and copying the link.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 24.06.2019 01:00
What are two ways to access the options for scaling and page orientation? click the home tab, then click alignment, or click the file tab. click the file tab, then click print, or click the page layout tab. click the page layout tab, or click the review tab. click the review tab, or click the home tab?
Answers: 2
question
Computers and Technology, 24.06.2019 08:10
Where are american poets found in the dewey decimal system
Answers: 1
question
Computers and Technology, 24.06.2019 12:00
An npn transistor is correctly biased and turned on if the a. base is negative. b. collector is negative. c. collector is positive with respect to the emitter and negative with respect to the base. d. collector is the most positive lead followed by the base.
Answers: 1
question
Computers and Technology, 24.06.2019 18:30
Jacking is a crime that takes place when a hacker misdirects url to a different site. the link itself looks safe, but the user is directed to an unsafe page
Answers: 1
You know the right answer?
You have successfully made a basic webpage calculator! Now that you’ve learned how to use HTML forms...
Questions
question
Social Studies, 25.08.2020 23:01
Questions on the website: 13722359