Hi, I am new here without any coding skills but willing to learn. I know how
to use html code. I am thinking of how to write the code for below scenario
to create a simple online customize calculator:
There is 1 box which allow us to enter any number=x (representing amount of money).
So whenever we entered a number in the box and click "CALCULATE" buton below the box,
there will be 3 results generated in 3 boxes below it based on the set of of rules
i.e.
1. if the amount entered is <21,000
Result 1 = 1.5%*x*12
Result 2 = 1.5%*x*48
Result 3 = 1.5%*x*120
2. if the amount entered is >=21,000 and <210,000
Result 1 = 1.8%*x*12
Result 2 = 1.8%*x*48
Result 3 = 1.8%*x*120
3. if the amount entered is >=210,000
Result 1 = 2.2%*x*12
Result 2 = 2.2%*x*48
Result 3 = 2.2%*x*120
I understand that this code will involve If...else if...else Statement..
Anyone can give me any references/examples similar to this scenario? Thanks.
Sorry, but you are wrong. It's not an error. Variables may be separated with commas when initialized by the var operator.
Hmm. You are indeed right, but that is not something to offer to a beginner, especially without any explanation. Semi-colons would have worked just as well.
__________________
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
I think, this is JavaScript basics, which must be learned first.
For myself, I see that is likely to cause confusion. I might perhaps write var x,y,z; but I would not do that if the variable was initialised with an expression such as you are using. I cannot see any advantage in that. But each to his taste!
__________________
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.