-
Notifications
You must be signed in to change notification settings - Fork 175
/
functions.js
32 lines (19 loc) · 1.26 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
// Defining Our Own Functions
// For each exercise below, write the function according to the requirements.
// Store the return value of the function call in a variable, and use console.log() to see the return value in the console.
// If a function takes parameters, call the function at least twice, passing different arguments each time.
// 1: Write a function named greeting that returns a string with a general greeting.
// 2: Write a function named customGreeting that returns a greeting WITH a specific name.
// 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.
// 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"