Skip to content

Commit 1f62859

Browse files
committed
less problem due to intruption
1 parent 2145680 commit 1f62859

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

problem_july_21.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//question no.9
2+
//create a function that will convert the ferenhite to celcius
3+
function converto(n){
4+
return n-3.8/18;
5+
}
6+
console.log(converto(30))
7+
8+
//question 10
9+
//calculate the sum of numbers in a array of number
10+
11+
let arr=[2,4,4,56,6]
12+
function sumcal(){
13+
let sum=0
14+
for(let i=0;i<arr.length;i++){
15+
sum+=arr[i]
16+
}
17+
console.log(sum)
18+
}
19+
sumcal(arr)
20+
21+
//question 11
22+
//calculate the average of the number in the array of number
23+
function average(){
24+
let average =0;
25+
for(let i=0; i<arr.length;i++){
26+
average+=arr[i]
27+
}
28+
average=average/arr.length
29+
console.log(average)
30+
}
31+
let ar = [1, 3, 9, 15, 90];
32+
average(ar)
33+
34+
//question 12
35+
//create the function that recieve the and array of numbers and return the array
36+
// containing the array only with positive number
37+
function positive(arr){
38+
let arr2=[]
39+
for(let i=0;i<arr.length;i++){
40+
let pos=arr[i];
41+
if(pos>0){
42+
arr2.push(pos)
43+
}
44+
}return arr2
45+
}
46+
let are = [-5, 10, -3, 12, -9, 5, 90, 0, 1];
47+
console.log(positive(are))
48+
49+
//question 13
50+
//find the maximum number in an array of numbers
51+
function findmax(arr){
52+
let max=0;
53+
for(let i=0; i<arr.length;i++){
54+
let temp=arr[i]
55+
if(temp>max){
56+
max=temp
57+
}
58+
}
59+
return max
60+
}
61+
let areee = [-5, 10, -3, 12, -9, 5, 90, 0, 1];
62+
console.log(findmax(areee))

0 commit comments

Comments
 (0)