-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassignment.js
93 lines (70 loc) · 1.99 KB
/
assignment.js
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// feet To Mile
function feetToMile(feet){
var Mile = feet/5280 ;
return Mile;
}
var result = feetToMile(5);
console.log(result);
// woodCalculator
function woodCalculator(chair,table,khat){
var chairCount = chair * 1;
var tableCount = table * 3;
var khatCount = khat * 5;
var totalWood = chairCount+tableCount+khatCount;
return totalWood;
}
var woodResult = woodCalculator(1,2,1);
console.log(woodResult);
// tinyFriend
function tinyFriend(persons){
var lowestName = persons[0] ;
for(var i = 0; i<persons.length; i++){
var currentName = persons[i];
if(currentName.length<lowestName.length){
lowestName = currentName;
}
}
return lowestName;
}
var smallestName = tinyFriend(["ariyanarif","ariyan","abdulbari",]);
console.log(smallestName);
// brickCalculator
function brickCalculator(perFloor){
var perfeet = 1000;
var totalBrick;
if(perFloor>0 && perFloor<=10){
totalBrick= perfeet*15*perFloor;
}
else if(perFloor>=11 && perFloor<=20){
totalBrick=perfeet*12*perFloor;
}
else{
totalBrick = perfeet*10*perFloor;
}
return totalBrick;
}
var result = brickCalculator(25);
console.log(result);
// Another solution of brickcalculator
function BrickCalculator(PerFloor) {
var brick ;
if(PerFloor<=10){
brick = PerFloor*1000*15;
}
else if(PerFloor<=20){
var firstpart = 10*1000*15;
var remaining = PerFloor - 10;
var secondpart = remaining * 1000*12;
brick = firstpart+secondpart;
}
else{
var firstpart = 10*1000*15;
var secondpart = 10*1000*12;//flor,brick,fit
var remaining = PerFloor - 20;
var thirdpart = remaining*1000*10;
brick = firstpart+secondpart+thirdpart;
}
return brick;
}
var finalResult =BrickCalculator(13)
console.log(finalResult);