-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassignment4.js
More file actions
60 lines (57 loc) · 1.76 KB
/
assignment4.js
File metadata and controls
60 lines (57 loc) · 1.76 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
//Qstn-1
function anaToVori(ana) {
if (typeof ana != "number" || ana < 0) {
return "wrong input enter Numbers only";
}
return ana / 16;
}
// console.log(anaToVori('1'));
// console.log(anaToVori(1));
//Qstn-2
function pandaCost(singara, samusa, jilapi) {
if (typeof singara != "number" || typeof samusa != "number" || typeof jilapi != "number" || samusa < 0 || singara < 0 || jilapi < 0) {
return "wrong input enter Numbers only";
}
const singara_price = 7,
samusa_price = 10,
jilapi_price = 15;
return ((singara * singara_price) + (samusa * samusa_price) + (jilapi * jilapi_price));
}
// console.log(pandaCost('4', '3', 1));
// console.log(pandaCost(4, 3, 1));
//Qstn-3
function picnicBudget(persons) {
if (typeof persons != "number" || persons < 0) {
return "wrong input enter Numbers only";
}
var budget = 0;
if (persons <= 100) {
budget = persons * 5000;
} else if (persons <= 200) {
let p1 = 100,
p2 = persons - 100;
budget = (p1 * 5000) + (p2 * 4000);
} else {
let p1 = 100,
p2 = 100,
p3 = persons - 200;
budget = (p1 * 5000) + (p2 * 4000) + (p3 * 3000);
}
return budget;
}
// console.log(picnicBudget("103"));
// console.log(picnicBudget(103));
//Qstn 4
function oddFriend(friend_list) {
if (typeof friend_list != "object") {
return "wrong input enter Array only";
}
for (let i = 0; i < friend_list.length; i++) {
if (friend_list[i].length % 2 != 0)
return friend_list[i];
else
continue;
}
}
// console.log(oddFriend(3));
// console.log(oddFriend(['fuad', 'fata', 'auvee', 'apon', 'shoyeb']));