forked from bloominstituteoftechnology/Precourse-Assessment
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassessment.js
More file actions
54 lines (46 loc) · 2.2 KB
/
assessment.js
File metadata and controls
54 lines (46 loc) · 2.2 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
// Work through the problems in this file. As you work through each problem periodically run: npm test
// Your function name and the string must match the instructions exactly otherwise the tests will fail.
// After writing your function uncomment the matching function reference at the bottom of the file.
// 1. Write a function called helloWorld that returns the string 'Hello World!'.
// 2. Write a function called lambdaSchool that has a single parameter called num.
// num will be a positive integer.
// If num is divisible by 3 return the string 'Lambda'
// If num is divisible by 5 return the string 'School'
// If num is divisible by 3 AND 5 return the string 'Lambda School' (notice the space)
// If num is NOT divisible by 3 or 5 then return num.
//
// Example:
// lambdaSchool(15); // returns 'Lambda School'
// lambdaSchool(8); // returns 8
// 3. Write a function called longestString that has a single parameter called strs.
// strs will be an array of strings.
// Return the longest string that is in strs.
// If there is a tie for the longest string then return the one that occurs first.
//
// Example:
// longestString(['hi', 'hello', 'ni hao', 'guten tag']); // returns 'guten tag'
// longestString(['JavaScript', 'HTML', 'CSS']); // returns 'JavaScript'
// 4. Write a function called computeUserAverageAge that has a single parameter called users
// users is an array of user objects.
// Each user object has a property called age that is a number.
// Compute the average age of all user objects in the users array.
// Round off the decimals if needed and return the number.
//
// Example:
// const users = [{
// name: 'Brendan Eich',
// age: 56,
// }, {
// name: 'Linus Torvalds',
// age: 48,
// }, {
// name: 'Margaret Hamilton',
// age: 81,
// }];
// computeUserAverage(users); // returns 62 (This number is rounded up from 61.6666)
module.exports = {
// helloWorld,
// lambdaSchool,
// longestString,
// computeUserAverageAge,
};