javascript calculator
JavaScript
function add (num1, num2) {
return Number(num1) + Number(num2);
}
function subtract (num1, num2) {
return Number(num1) - Number(num2);
}
function multiply (num1, num2) {
return num1 * num2;
}
function divide (num1, num2) {
return num1 / num2;
}let add =(...params) => {
let sum = 0;
params.forEach(el =>{
sum = sum + parseInt(el);
})
return sum
}
document.querySelector('.add').addEventListener('click' , function (e) {
const adder = document.querySelector('.addinput').value
const meow = adder.split(',')
let result = add(...meow)
if (isNaN(result)) {
result = 'ENTER A NUMBER'
}
document.querySelector('.result').textContent = result
})
let times =(...params) => {
let multiply = 1;
params.forEach(el =>{
multiply = multiply * el;
})
return multiply
}
document.querySelector('.multiply').addEventListener('click' , function (e) {
const multiplier = document.querySelector('.multiplyinput').value
const moo = multiplier.split(',')
let product = times(...moo)
if (isNaN(product)) {
product = 'ENTER A NUMBER'
}
document.querySelector('.product').textContent = product
})
let subtract =(...params) => {
let diff = 0;
diff = params[0] - params[1]
return diff
}
document.querySelector('.subtract').addEventListener('click' , function (e) {
const subtracter = document.querySelector('.subtractinput').value
const woof = subtracter.split(',')
let diff = subtract(...woof)
if (isNaN(diff)) {
diff = 'ENTER A NUMBER'
}
document.querySelector('.difference').textContent = diff
})
let divide =(...params) => {
let quotient = 0;
quotient = params[0] / params[1]
return quotient
}
document.querySelector('.divide').addEventListener('click' , function (e) {
const divider = document.querySelector('.divideinput').value
const moo2 = divider.split(',')
let quotient = divide(...moo2)
if (isNaN(quotient)) {
quotient = 'ENTER A NUMBER'
}
document.querySelector('.quotient').textContent = quotient
})
Also in JavaScript:
- Title
- aos js cdn
- Category
- JavaScript
- Title
- if alternative javascript
- Category
- JavaScript
- Title
- how to get timestamp in javascript of a date object
- Category
- JavaScript
- Title
- javascript check empty property
- Category
- JavaScript
- Title
- javascript check if browser is ie
- Category
- JavaScript
- Title
- convert negative number to positive in javascript
- Category
- JavaScript
- Title
- clear formarray in angular 6
- Category
- JavaScript
- Title
- how to make a stopwatch using js
- Category
- JavaScript
- Title
- javascript break out of loop
- Category
- JavaScript
- Title
- javascript class click event
- Category
- JavaScript
- Title
- iterate through object array javascript
- Category
- JavaScript
- Title
- Factorial Number
- Category
- JavaScript
- Title
- character to ascii in js
- Category
- JavaScript
- Title
- javascript array sort
- Category
- JavaScript
- Title
- jalali moment get milisocnds
- Category
- JavaScript
- Title
- check if message mentions users discord js
- Category
- JavaScript
- Title
- .pop js
- Category
- JavaScript
- Title
- alternative for componentdidmount
- Category
- JavaScript
- Title
- heroku failed to run files from static folder in node
- Category
- JavaScript
- Title
- array dia semana javascript
- Category
- JavaScript
- Title
- href back page javascript
- Category
- JavaScript
- Title
- how to write a program that shows a random number between 1 and 100 in your browser
- Category
- JavaScript
- Title
- angularjs cdn
- Category
- JavaScript
- Title
- get selected text of html dropdown in javascript
- Category
- JavaScript
- Title
- exercism.io bob solution
- Category
- JavaScript
- Title
- hide div in javascript
- Category
- JavaScript
- Title
- background url reactjs
- Category
- JavaScript
- Title
- javascript check if dom element exists
- Category
- JavaScript
- Title
- billie eilish
- Category
- JavaScript
- Title
- dropzone csrf codeigniter
- Category
- JavaScript
- Title
- angular wait all subscriptions
- Category
- JavaScript
- Title
- how to do radio button validation in jquery
- Category
- JavaScript
- Title
- angular material checkbox
- Category
- JavaScript
- Title
- javascript canvas gamma correction
- Category
- JavaScript
- Title
- how to add array numbers in javascript
- Category
- JavaScript
- Title
- bracket notation javascript
- Category
- JavaScript
- Title
- javascript add item to list
- Category
- JavaScript
- Title
- how to see if a web site is useing react
- Category
- JavaScript
- Title
- function js
- Category
- JavaScript
- Title
- how to access a database in express
- Category
- JavaScript
- Title
- function inside object javascript
- Category
- JavaScript
- Title
- disable right click javascript
- Category
- JavaScript
- Title
- addEventListener
- Category
- JavaScript
- Title
- javascript ajax
- Category
- JavaScript
- Title
- implementing node js app on server and runing npm
- Category
- JavaScript
- Title
- copy php array to javascript
- Category
- JavaScript
- Title
- how to define variable in javascript
- Category
- JavaScript
- Title
- how to send an alert in javascript
- Category
- JavaScript
- Title
- Javascript check for hash in URL
- Category
- JavaScript
- Title
- adding cors in angular
- Category
- JavaScript
- Title
- how to check reactjs version in command prompt
- Category
- JavaScript
- Title
- convert jquery to string
- Category
- JavaScript
- Title
- angular stoppropagatio
- Category
- JavaScript
- Title
- conditional rendering with radio buttons
- Category
- JavaScript
- Title
- how to displayan inteiger to a tenth in javascript
- Category
- JavaScript
- Title
- add dev dependency yarn
- Category
- JavaScript
- Title
- hit enter button lick in js
- Category
- JavaScript
- Title
- javascript check if variable is a jquery object
- Category
- JavaScript
- Title
- (function (g, d, a) {})(window, document, jQuery);
- Category
- JavaScript
- Title
- how to insert a value into an array javascript
- Category
- JavaScript
- Title
- color js
- Category
- JavaScript
- Title
- how to add button react native app.js
- Category
- JavaScript
- Title
- check when keyup an input from a specific form jquery
- Category
- JavaScript
- Title
- how to make a javascript game
- Category
- JavaScript
- Title
- export apk react native
- Category
- JavaScript
- Title
- anime.js morph svg d value
- Category
- JavaScript
- Title
- how to add object to array javascript
- Category
- JavaScript
- Title
- how to make a property important in javascript
- Category
- JavaScript
- Title
- how to disable cash through get request in angular
- Category
- JavaScript
- Title
- javascript canvas reset transform
- Category
- JavaScript
- Title
- convert json to 2d array
- Category
- JavaScript
- Title
- html hide till button click
- Category
- JavaScript
- Title
- how to remove an object from array in react native
- Category
- JavaScript
- Title
- Encrypt in PHP openssl and decrypt in javascript CryptoJS
- Category
- JavaScript
- Title
- how to add an array to another array in javascript
- Category
- JavaScript
- Title
- how to concatenate strings and variables in javascript
- Category
- JavaScript
- Title
- casl react
- Category
- JavaScript
- Title
- document.ready()
- Category
- JavaScript
- Title
- angular 9 change menu link item at runtime
- Category
- JavaScript
- Title
- atom javascript es6 linter
- Category
- JavaScript
- Title
- change dxform label angular
- Category
- JavaScript
- Title
- encode url javascript
- Category
- JavaScript
- Title
- for of array javascript
- Category
- JavaScript
- Title
- beautify json python
- Category
- JavaScript
- Title
- count occurrences of character in string javascript
- Category
- JavaScript
- Title
- How to write on a web page javascript
- Category
- JavaScript
- Title
- check if checkbox is checked jquery
- Category
- JavaScript
- Title
- embed jquery
- Category
- JavaScript
- Title
- declarar una funcion javascript
- Category
- JavaScript
- Title
- angular right click on link
- Category
- JavaScript
- Title
- inline javascript html
- Category
- JavaScript
- Title
- device height react native
- Category
- JavaScript
- Title
- enter event in jquery
- Category
- JavaScript
- Title
- data binding on checkbox angular
- Category
- JavaScript
- Title
- divide intagers javascript
- Category
- JavaScript
- Title
- http server node example
- Category
- JavaScript
- Title
- equal to or more than javascript
- Category
- JavaScript
- Title
- javascrip reverse text
- Category
- JavaScript
- Title
- javascript array split chunk
- Category
- JavaScript
- Title
- javascript calculator
- Category
- JavaScript