Creator: Thom Page
Topics: Problem solving with functions
History: This lesson was taken from [SEIR-MAE](https://git.generalassemb.ly/Software-Engineering-Immersive-Remote/SEIR-MAE-INSTRUCTORS/blob/master/unit_1/w02d3/student_labs/morning_lab.md)
- Do the following in a
repl.itor environment of your choice. - Fork and clone this respository
- Add a file to this project that contains both your name and your point person's name (
taylor-bruno.js) - Make a pull request and make the title or your PR also contain both your own and your point-instructor's name, like the
jsfile.
Remember:
- one step at a time (test thoroughly each step)
- researching a step is excellent (although time-consuming)
Write a function calculateCube that takes a single number and prints the volume of a cube made from that number.
console.log(calculateCube(5));=> 125
Write a function isAVowel that takes a character (i.e. a string of length 1) and returns true if it is a vowel, false otherwise. The vowel could be upper or lower case.
console.log(isAVowel("a"));=> true
Write a function getTwoLengths that accepts two parameters (strings). The function should return an array of numbers where each number is the length of the corresponding string.
console.log(getTwoLengths("Hank", "Hippopopalous"));=> [4, 13]
Write a function getMultipleLengths that accepts a single parameter as an argument: an array of strings. The function should return an array of numbers where each number is the length of the corresponding string.
console.log(getMultipleLengths(["hello", "what", "is", "up", "dude"]));=> [5, 4, 2, 2, 4]
Creator: Thom Page
Topics: Problem solving with functions
History: This lesson was taken from [SEIR-MAE](https://git.generalassemb.ly/Software-Engineering-Immersive-Remote/SEIR-MAE-INSTRUCTORS/blob/master/unit_1/w02d3/student_labs/afternoon_lab.md)
Define a function maxOfThree that takes three numbers as arguments and returns the largest of them. If all numbers are the same, it doesn't matter which one is returned. If the two largest numbers are the same, one of them should be returned.
console.log(maxOfThree(6, 9, 1));=> 9
Write a function printLongestWord that accepts a single argument, an array of strings. The method should return the longest word in the array. In case of a tie, the method should return the word that appears first in the array.
console.log(printLongestWord(["BoJack", "Princess", "Diane", "a", "Max", "Peanutbutter", "big", "blob"]));=> "Peanutbutter"
Write a Javascript function called transmogrify. This function should accept three arguments, which you can assume will be numbers. Your function should return the "transmogrified" result.
The transmogrified result of three numbers is the product of the first two numbers, raised to the power of the third number.
For example, the transmogrified result of 5, 3, and 2 is (5 times 3) to the power of 2 is 225.
console.log(transmogrify(5, 3, 2));=> 225
-
Write a function that takes a parameter, a number. The function should print the Fibonacci sequence up to that number.
-
Adjust the function to push the even numbered values into an array.
-
Adjust the function to return the summed value of the array.
-
Find the sum of the even numbered values that do not exceed four million.
Can you find the needle in the haystack?
Write a function findNeedle() that takes an array full of junk but contains one "needle"
After your function finds the needle it should return a message (as a string) that says:
"found the needle at postition" plus the index it found the needle so:
findNeedle(['hay', 'junk', 'hay', 'hay', 'moreJunk', 'needle', 'randomJunk'])
Should return:
"found the needle at position 5"
Given an array, return the sum of only the positive numbers
[1, -4, 7, 12] => 1 + 7 + 12 = 20
Join CodeWars and find your own challenges to solve! Find a great one? Share it in slack!