language | tags | type | resources |
---|---|---|---|
JavaScript, js |
selectors |
lab |
4 |
Students will work in groups to create a calculator that accepts user input using jQuery event listeners and JavaScript functions, if/else or switch statements, and jQuery val methods.
- Be object oriented.
- the calculator should take use jQuery selectors to get the input for 2 separate numbers and 1 operation: '+', '-', '*', '/'.
- When the user clicks the equals button, the calculator should update the result
h2
tag with the result. 1. If the user leaves a number field blank or inserts some input that is not a number then h2 with id="result" should instead print the error message: "Sorry, one of those is not a valid number!". 2. If the operation inserted is not one of the valid accepted operations then the error message should then read "Sorry, not a valid operation!"
See a live working example of the simple calculator here
##Before You Start
# Install jasmine:
gem sources -a http://flatiron:[email protected]
gem install ironboard
# Run Jasmine test suite:
ironboard # runs only in the terminal
ironboard -b # runs also in the browser
US/docs/Web/JavaScript/Reference/Statements/function)