-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
28 lines (24 loc) · 1.13 KB
/
main.js
File metadata and controls
28 lines (24 loc) · 1.13 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
/*
Function - Random Argument Challenge
====================================
Create Function showDetails
Function Accept 3 Parameters [a, b, c]
Data Types For Info Is
- String => Name
- Number => Age
- Boolean => Status
Argument Is Random
Data Is Not Sorted Output Depend On Data Types
- Use Ternary Conditional Operator
*/
function showDetails(a, b, c) {
let name, age, status;
typeof a === "string" ? name = a : typeof b === "string" ? name = b : name = c;
typeof a === "number" ? age = a : typeof b === "number" ? age = b : age = c;
typeof a === "boolean" ? status = a : typeof b === "boolean" ? status = b : status = c;
console.log(`"Hello ${name}, Your Age Is ${age}, You Are ${status ? "Available" : "Not Available"} For Hire"`);
}
showDetails("Osama", 38, true); // "Hello Osama, Your Age Is 38, You Are Available For Hire"
showDetails(38, "Osama", true); // "Hello Osama, Your Age Is 38, You Are Available For Hire"
showDetails(true, 38, "Osama"); // "Hello Osama, Your Age Is 38, You Are Available For Hire"
showDetails(false, "Osama", 38); // "Hello Osama, Your Age Is 38, You Are Not Available For Hire"