From c9717af73a6530701f9a38880c91459564785085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=85=B7=E6=9D=B0?= <1657738299@qq.com> Date: Tue, 30 Apr 2019 15:08:28 +0800 Subject: [PATCH] one work --- new_file.js | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 new_file.js diff --git a/new_file.js b/new_file.js new file mode 100644 index 0000000..b338520 --- /dev/null +++ b/new_file.js @@ -0,0 +1,118 @@ +//创建一个函数用以找到两个数字中较大的数。例如:给函数传递参数4、5,返回5。 + function sum(n1,n2){ + if(n1>n2){ + return n1} + else{ + return n2}; + }; +Console.log(sum(4,5)) + +//创建一个函数用以判断一个数字是否是质数。例如:给函数传递参数5,返回true;给定函数4,返回false。 + function num(n){ + if(n%1==0 && n%n==0){ + return'true'} + else{ + return'false'};}; +Console.log(num(7)) + +//创建一个函数,运用第2题的函数找到给定区间内的质数。例如:给函数传递参数1、1000,函数将返回1-1000之间的所有质数。 + function number(n,n1){ + + for(var i=n;ib){ + if(c>a){ + alert(c); + }; + else{ + alert(a); + } + }; + else{ + if(c>b){ + alert(c); + }; + else{ + alert(b); + } + } + }; +Console.log(bigger(1,2,3)) + +//创建一个函数用以判断一个数字是否是水仙花数。例如:给函数传递参数153,返回true。 + function flower(n){ + + var length=n.length; + var content=n.split(""); + var result=0; + for(var i=0;ib){ + t = a; + a = b; + b = t + } + if(a > c){ + t = a; + a = c; + c = t; + } + if(b > c){ + t = b; + b = c; + c = t; + } + document.write( a , b , c ); + } +console.log(smallr(5,8,6)) -- Gitee