forked from turingschool/m0_fe_functions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.js
48 lines (36 loc) · 1.68 KB
/
functions.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
// Defining Our Own Functions
// For each exercise below, write the function according to the requirements.
// Call each method at least twice and store the return value in a variable.
// Use console.log() to see the return value in the console.
// 1: Write a function named greeting that returns a string with a general greeting.
function greeting() {
return "Hello, there. How you doin?";
}
// 2: Write a function named customGreeting that returns a greeting WITH a specific name.
function customGreeting(name) {
return `Helloooo this is ${name}`;
}
var message1 = customGreeting("Henry")
console.log(message);
var message2 = customGreeting("hard")
console.log(message)
// 3: Write a function named greetPerson that takes in 3 strings, a first, middle, and last name, and returns a sentence with the full name.
function greetPerson(firstName, midName, lastName) {
return `Sup ${firstName} ${midName} ${lastName}?!`
}
var fullName1 = greetPerson("Henry", "Chandler", "Long")
console.log(fullName1)
var fullName2 = greetPerson("Lacey", "Arlene", "Long")
console.log(fullName2)
// 4: Write a function named square that takes in one number, and returns the square of that number.
// BONUS: Print a sentence that interpolates the return value of your square function.
// 5: Write a function named checkStock that satisfies the following interaction pattern:
// Hint: You will only write one checkStock function that checks the quantity and then prints the corresponding statement.
checkStock(4, "Coffee");
// => "Coffee is stocked"
checkStock(3, "Tortillas");
// => "Tortillas - running LOW"
checkStock(0, "Cheese");
// => "Cheese - OUT of stock!"
checkStock(1, "Salsa");
// => "Salsa - running LOW"