-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassignment_loops.js
More file actions
72 lines (68 loc) · 1.8 KB
/
assignment_loops.js
File metadata and controls
72 lines (68 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*function isPrime(num){
if(num<=1) {
return false;
}
if(num==2) {
return true;
}
for(let i=2;i<num/2;i++){
if(num%i===0){
return false;
}
return true
}
}
function display(start,end){
let arr = []
for(let i=start;i<=end;i++){
if(isPrime(i)){
arr.push(i)
}
}
return (arr)
}
console.log(display(1,30 ));*/
/*let arr=[1,2,3,4,5,6,7]
function check(num1){
for(let i=0;i<=arr.length;i++){
if(arr[i]==num1){
console.log(true)
}
/* else{
console.log(false)
}*/
/* }
}
check(3)*/
function rank(percentStd1,percentStd2,percentStd3){
// let a=[percentStd1,percentStd2,percentStd3]
//for(let i=0;i<=a.length;i++){
if(percentStd1>percentStd2&&percentStd1>percentStd3){
if(percentStd2>percentStd3){
console.log(`student 1 is 1st,student 2 is second and student 3 is third`)
}
else{
console.log(`student 1 is 1st,student 3 is second and student 2 is third`)
}
}
else if(percentStd2>percentStd1&&percentStd2>percentStd3){
if(percentStd1>percentStd3){
console.log(`student 2 is 1st,student 1 is second and student 3 is third`)
}
else{
console.log(`student 2 is 1st,student 3 is second and student 1 is third`)
}
}
else{
if(percentStd1>percentStd2){
console.log(`student 3 is 1st,student 1 is second and student 2 is third`)
}
else{
console.log(`student 3 is 1st,student 2 is second and student 1 is third`)
}
}
}
//}
rank(90,5,7)
rank(9,90,7)
rank(9,7,90)