Write a function that returns the number of truthy values in a given array. Return 0 if given an empty array.
// Examples
countTruthy([true, false, false, true, false]) // ➞ 2
countTruthy([false, false, false, false]) // ➞ 0
countTruthy([]) // ➞ 0
Create a function that takes two numbers as arguments (num, steps) that returns an array of multiples of num up to the steps. for example
arrayOfMultiples(1, 2); // ➞ means [1*1, 1*2] = [1, 2]
arrayOfMultiples(20, 3); // ➞ means [20*1, 20*2, 20*3] = [20, 40, 60]
arrayOfMultiples(7, 5); // ➞ [7, 14, 21, 28, 35]
arrayOfMultiples(12, 10); // ➞ [12, 24, 36, 48, 60, 72, 84, 96, 108, 120]
arrayOfMultiples(17, 6); // ➞ [17, 34, 51, 68, 85, 102]
Write a function that takes a number as an argument. Add up all the numbers from 1 to that number.
For example, if the input is 4 then your function should return 10 because 1 + 2 + 3 + 4 = 10
.
Examples
addUp(4); // ➞ 10
addUp(13); // ➞ 91
addUp(600); // ➞ 180300
A word is on the loose and now has tried to hide amongst a crowd of tall letters! Help write a function to detect what the word is, knowing the following rules:
- The wanted word is in lowercase.
- The crowd of letters is all in uppercase.
- the word will be spread out amongst the random letters, but their letters remain in the same order.
Examples
detectWord("UcUNFYGaFYFYGtNUH"); // ➞ "cat"
detectWord("bEEFGBuFBRrHgUHlNFYaYr"); // ➞ "burglar"
detectWord("YFemHUFBbezFBYzFBYLleGBYEFGBMENTment"); // ➞ "embezzlement"
Create the function that takes an array with objects and returns the sum of people's budgets.
Examples
getBudgets([
{ name: "father", age: 32, budget: 23000 },
{ name: "mother", age: 29, budget: 40000 },
{ name: "son", age: 16, budget: 2700 }
]); // ➞ 65700
getBudgets([
{ name: "John", age: 21, budget: 29000 },
{ name: "Steve", age: 32, budget: 32000 },
{ name: "Martin", age: 16, budget: 1600 }
]); // ➞ 62600