-
Notifications
You must be signed in to change notification settings - Fork 33
/
code-challenges.js
49 lines (32 loc) · 1.7 KB
/
code-challenges.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
// UNIT 1 ASSESSMENT: Coding Practical Questions
// Please read all questions thoroughly
// Pseudo coding is REQUIRED
// If you get stuck, leave comments to help us understand your thought process
// Reminder: Ensure you are in the correct directory
// Run the file with the following command: $ node code-challenges.js
// --------------------INSTRUCTOR EXAMPLE: Create a function that takes in two strings and evaluates which of the strings has more characters. Use the test variables provided.
const fruit1 = "apple"
const fruit2 = "banana"
// Expected outcome: "banana"
const fruit3 = "cherry"
const fruit4 = "kiwi"
// Expected outcome: "cherry"
// Pseudo code:
// --------------------1) Create a function that takes in an array of numbers and returns the sum of all the numbers. Use the test variables provided below.
const padres1984WorldSeriesRuns = [2, 5, 2, 2, 4]
// Expected output: 15
const padres1998WorldSeriesRuns = [6, 3, 5, 3]
// Expected output: 17
// Pseudo code:
// --------------------2) Create a function that takes in a string and returns the string with all the characters in reversed order. Use the test variable provided below.
const lesMiserables = "Jean Valjean"
// Expected output: "naejlaV naeJ"
const lionKing = "Simba"
// Expected output: "abmiS"
// Pseudo code:
// --------------------3) Create a function that takes in an array and returns an array with only the items from the third, fourth, and fifth indexes. Use the test variable provided below.
const stockExchange = [13, 34, -4, 42, 5, -5, 10, 27, 42, 10]
// Expected output: [42, 5, -5]
const cohortList = ["Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot"]
// Expected output: ["Delta", "Echo", "Foxtrot"]
// Pseudo code: