当前位置:网站首页>JS to judge the odd and even function and find the function of circular area
JS to judge the odd and even function and find the function of circular area
2022-06-27 07:35:00 【I am the sun?】
Define a function , Judge whether it is even , If so, return true, If not, return to false
traditional method :
Code :
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<script type="text/javascript">
function isOdd(a){
if(a % 2 == 0)
return true;
else
return false;
}
var result = isOdd(1);
document.write(result);
</script>
</head>
<body>
</body>
</html>
Running results :
Simplify the method (a%2==0 It was Boole's judgment ):
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<script type="text/javascript">
function isOdd(a){
return a % 2 == 0;
}
var result = isOdd(112);
document.write(result);
</script>
</head>
<body>
</body>
</html>
Running results :
Define a function , You can calculate the area of a circle based on its radius , And return the calculation results
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<script type="text/javascript">
function area(r){
return 3.14 * r * r;
}
var result = area(5);
document.write(" The area of a circle is :" + result);
</script>
</head>
<body>
</body>
</html>
Running results :
边栏推荐
- R language analyzing wine data
- (已解决) MINet 进行测试时报错如下 raise NotImplementedError
- PostgreSQL encounters permission denied in Windows system
- 专业四第二周自测
- Use uview to enable tabbar to display the corresponding number of tabbars according to permissions
- 延时队列`DelayQueue`
- R language consumption behavior statistics based on association rules and cluster analysis
- Self test in the second week of major 4
- Speech signal processing - concept (I): time spectrum (horizontal axis: time; vertical axis: amplitude), spectrum (horizontal axis: frequency; vertical axis: amplitude) -- Fourier transform -- > time
- js用switch语句根据1-7输出对应英文星期几
猜你喜欢

JS, and output from small to large

一个人管理1000台服务器?这款自动化运维工具一定要掌握

How to write controller layer code gracefully?

(已解决) MINet 进行测试时报错如下 raise NotImplementedError
![[Kevin's third play in a row] is rust really slower than C? Further analyze queen micro assessment](/img/ac/44e0ecd04fbea5efd39d2cc75dea59.jpg)
[Kevin's third play in a row] is rust really slower than C? Further analyze queen micro assessment
![[compilation principles] review outline of compilation principles of Shandong University](/img/a6/b522a728ff21085411e7452f95872a.png)
[compilation principles] review outline of compilation principles of Shandong University

Multi table associated query -- 07 -- hash join

Xiaomi Interviewer: let's talk about the proficient Registration Center for three days and three nights
![Speech signal processing - concept (II): amplitude spectrum (STFT spectrum), Mel spectrum [the deep learning of speech mainly uses amplitude spectrum and Mel spectrum] [extracted with librosa or torch](/img/b3/6c8d9fc66e2a4dbdc0dd40179266d3.png)
Speech signal processing - concept (II): amplitude spectrum (STFT spectrum), Mel spectrum [the deep learning of speech mainly uses amplitude spectrum and Mel spectrum] [extracted with librosa or torch
![[graduation season] graduation is the new beginning of your life journey. Are you ready](/img/4e/aa763455da974d9576a31568fc6625.jpg)
[graduation season] graduation is the new beginning of your life journey. Are you ready
随机推荐
【软件工程】山东大学软件工程复习提纲
boundvalueops和opsforvalue区别
mysql关于自增和不能为空
log4j:WARN No such property [zipPermission] in org. apache. log4j. RollingFileAppender.
window右键管理
uview的安装和功能
What is a flotation machine?
Origin of forward slash and backslash
js输出1-100之间所有的质数并求总个数
log4j:WARN No such property [zipPermission] in org.apache.log4j.RollingFileAppender.
Custom palette for ggplot2
One person manages 1000 servers? This automatic operation and maintenance tool must be mastered
(已解决) MINet 进行测试时报错如下 raise NotImplementedError
[Software Engineering] software engineering review outline of Shandong University
Error in idea connection database
Rust中的Pin详解
JDBC事务提交事例
多表联查--07--- Hash join
Speech signal processing - concept (I): time spectrum (horizontal axis: time; vertical axis: amplitude), spectrum (horizontal axis: frequency; vertical axis: amplitude) -- Fourier transform -- > time
Configuring FTP, enterprise official website, database and other methods for ECS