Hi! Is there a way to make a calculator from scratch using Velo? Something like what Google uses ( Google Calculator ), but somewhat simplified with function.
Before you start to code somethin like that…
https://www.media-junkie.com/html-calculator
First make sure you are able to understand RETURN-FUNCTIONS.
Okay!
After we do that, what do we do?
@paxaurora6
After you have understood return-functions → you start to code some of them.
Which functions/operations is a calculator able to manage? Let us pick-up the most simple ones…
- addition
- substraction
- multiplication
- Division
Of course there are much more operations and functios, but start first with simple programming.
Ok, let’s generate a simple addition-return-function.
What will this function be able to do?
The function will be able to generate a sum of 2 numbers, sum them together.
function addition(a, b){
return(a+b)
}
So, now you generate to variables (x,y) or (a,b) or which ever you want, and give them a VALUE…
let x=33;
let y = 44;
Now you start your -->ADDITION-function with a click onto a ±button.
$w.onReady(()=>{
$w('#myPlusButton').onClick((){
addition(x,y)
// or directly....
addition(33, 44)
});
});
What do you get as RESULT?