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

How to implement multiplication and addition in JavaScript

藏色散人
Release: 2021-11-09 15:28:43
Original
2299 people have browsed it

How to implement multiplication and addition in JavaScript: 1. Create the add and take functions through function and set two parameters; 2. Set the mathematical formulas for addition and multiplication; 3. Enter the parameters and display them in the browser Just output the calculation results in .

How to implement multiplication and addition in JavaScript

The operating environment of this article: windows7 system, javascript version 1.8.5, Dell G3 computer.

How to implement multiplication and addition in JavaScript?

js implementation of addition:

//创建一个add函数,并定义两个参数x,y
function add(x,y){
//设置相加的数学公式
    return x + y;
}
//在浏览器中输出计算结果
document.write(add(6,8)+"<br />");
Copy after login

js implementation of multiplication:

//创建一个take函数,并定义两个参数x,y
function take(x,y){
/设置相乘的数学公式
    return x * y;
}
//在浏览器中输出计算结果
document.write(take(5,6));
Copy after login

Recommended study: "javascript basic tutorial"

The above is the detailed content of How to implement multiplication and addition in JavaScript. 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