This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
In this exercise, we will be given an array of 2 or more numbers. | |
We will then have to find the two largest numbers in that array, and sum them together. | |
Input | |
const sumLargestNumbers = function(data) { | |
// Put your solution here | |
}; | |
console.log(sumLargestNumbers([1, 10])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
For this kata, we'll be adding only the numbers in the array which match the given condition. | |
Input | |
const conditionalSum = function(values, condition) { | |
// Your code here | |
}; | |
console.log(conditionalSum([1, 2, 3, 4, 5], "even")); | |
console.log(conditionalSum([1, 2, 3, 4, 5], "odd")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
In this exercise, we will be counting the number of vowels that appear in a given string. For this exercise, consider the following to be vowels: a, e, i, o, and u. | |
INPUT | |
const numberOfVowels = function(data) { | |
// Put your solution here | |
}; | |
console.log(numberOfVowels("orange")); //3 | |
console.log(numberOfVowels("lighthouse labs")); //5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
In this exercise, we will be given a list of instructors and have to determine which instructor has the longest name. | |
Input | |
const instructorWithLongestName = function(instructors) { | |
// Put your solution here | |
}; | |
console.log(instructorWithLongestName([ | |
{name: "Samuel", course: "iOS"}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Kata 5 - Percent Encoded String | |
In this exercise, we will be given a normal string of words and turn it into a percent-encoded string by replacing all whitespace with %20. | |
Percent Encoding | |
Take a look at the following URL, specifically the last part: | |
This URL will perform a google search for the term "lighthouse labs". Notice that when the string "lighthouse labs" is part of a URL, the space is replaced with %20. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
We need to write a function called whereCanIPark() that returns the coordinates of an available parking spot for the vehicle, | |
or returns false if there is no available spot. Our function receives an array of arrays representing parking spots, | |
and a string with type of the vehicle that is looking for a parking spot. | |
*/ | |
const whereCanIPark = function (spots, vehicle) { | |
for(let y = 0; y < spots.length; y++){ | |
for(let x = 0; x < spots[y].length; x++){ | |
if(vehicle === 'regular'){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
For this challenge we will implement a function called checkAir(), which will check a collection of air samples. | |
The function will take in two arguments. The first argument is an array of strings, where each string represents | |
a small air sample that is either clean or dirty. The second argument is a number representing the highest | |
acceptable amount of dirty samples. For example, a threshold of 0.4 means that there must be less than 40% of | |
total samples classified as dirty for our air to be considered clean. Our function must return Polluted if there | |
are too many dirty air samples, or Clean if the proportion of dirty samples is below the threshold. | |
*/ | |
const checkAir = function (samples, threshold) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Create a function named repeatNumbers that will return a string with each of the given | |
values repeated the appropriate number of times, if there are multiple sets of values | |
each set should be separated by a comma. If there is only one set of values then you | |
should omit the comma. | |
*/ | |
const repeatNumbers = function(data) { | |
let str = ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Create a function named multiplicationTable that receives a number maxValue as input | |
and creates a square multiplication table where maxValue is the largest value in the table. | |
*/ | |
const multiplicationTable = function(maxValue) { | |
let i = ''; | |
for(let y = 1; y <= maxValue; y++){ | |
for(let x = 1; x <= maxValue; x++){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const PI = 3.14159 ; | |
const sphereVolume = function (radius) { | |
return 4 / 3 * PI * Math.pow(radius, 3); | |
} | |
// console.log(4186 < sphereVolume(10) && sphereVolume(10) < 4189); | |
const coneVolume = function (radius, height) { | |
return PI * Math.pow(radius, 2) * height / 3; |
OlderNewer