Home > Web Front-end > JS Tutorial > body text

JS simulation supermarket simple checkout applet code analysis

韦小宝
Release: 2018-01-19 10:34:15
Original
2711 people have browsed it

This article introduces you to the JS simple supermarket cashier applet code through example code. It is very good and has the value of reference and learning js. Friends who are interested in JS can refer to it

No nonsense Without further ado, I will post the code directly for you. The specific code is as follows:

 <script type="text/javascript">
 // 1.编写一个程序,计算增加后的工资。要求基本工资大于等于1000元,增加20%的工资;若小于1000元且大于等于800元,则增加15%,若小于800元,则增加10%工资。
 var basepay = parseInt(prompt("请输入您的工资:"));//初始工资
 var pay1 = basepay+(basepay*0.2);//大于等于1000元,增加20%的工资
 var pay2 = basepay+(basepay*0.15);//小于1000元且大于等于800元,增加15%的工资
 var pay3 = basepay+(basepay*0.1);//小于800元,增加10%的工资
     if(basepay>=1000){
      document.write("您的总工资为:"+pay1+"元");
     }else if(800<=basepay&&basepay<1000){
      document.write("您的总工资为:"+pay2+"元");
     }else{
     document.write("您的总工资为:"+pay3+"元");
     }
</script>
Copy after login

The above is the code analysis of the JS simulated supermarket simple checkout applet introduced by the editor. I hope it will be useful to you. help! !

Related recommendations:

5 JavaScript algorithms for deleting duplicate elements from arrays

Throttle and prevention of JavaScript functions Detailed explanation of debounce

JavaScript HTML clock effect simple implementation method

The above is the detailed content of JS simulation supermarket simple checkout applet code analysis. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!