This file contains hidden or 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
// 12/21/2015 | |
//Use a while loop, a for loop, and a forEach loop to find the largest number in an array. | |
//Use the following array for each of these loops. | |
//[1,5,2,9,6,3] | |
---------------------------------------------------------------------------------------------------- | |
//My while loop solution: | |
var max=0; | |
var i=0; |
This file contains hidden or 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
// 12/21/2015 | |
// .reduce() method | |
function product(array){ | |
var answer=array.reduce(function(a,b){ | |
return a*b | |
}) | |
return answer | |
} |
This file contains hidden or 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
// 12/21/2015 | |
//This program runs well but we need to make it more elegant. | |
// Try to rewrite the code of the function factorial in way to use recursion. | |
// You can not use looping(for, while, forEach). | |
// Return examples | |
// factorial(3)=>3 x 2 x 1 = 6 | |
// factorial(2)=>2 x 1 = 2 | |
// factorial(0)=>1 = 1 | |
// My Solution: |
This file contains hidden or 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
// 12/22/2015 | |
// Make a program that filters a list of strings and returns a list | |
// with only your friends name in it. All your friends only have | |
// four letter in their name. | |
// Ex: Input = ["Ryan", "Kieran", "Jason", "Yous"], | |
// Output = ["Ryan", "Yous"] | |
// My Solution: |
This file contains hidden or 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
// 12/22/2015 | |
// In Your class You have started lessons about Arithmetic Progression. | |
// Because You are also a programmer, You have decided to write | |
// a function arithmetic_sequence_sum(a, r, n), that will print | |
// SUM of the first n elementh of the sequence with the given | |
// constant r and first elementh a | |
// For example arithmetic_sequence_sum(2, 3, 5) | |
// Should return: 40 |
This file contains hidden or 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
// 12/22/2015 | |
// Write a function uniq that takes in an array arr then returns | |
// unique items of arr. | |
// For example | |
// uniq(['a', 'b', 'a']) === ['a', 'b'] | |
// My Solution: |
This file contains hidden or 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
// 12/22/2015 | |
// Multiples of 3 and 5 | |
// If we list all the natural numbers below 10 that are multiples | |
// of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. | |
// Find the sum of all the multiples of 3 or 5 below 1000. | |
// My Solution: |
This file contains hidden or 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
// 12/22/2015 | |
// You might know some pretty large perfect squares. But what about the NEXT one? | |
// Complete the findNextSquare method that finds the next integral perfect square after the one passed as a parameter. Recall that | |
an integral perfect square is an integer n such that sqrt(n) is also an integer. | |
// If the parameter is itself not a perfect square, than -1 should be returned. You may assume the parameter is positive. | |
// Examples: | |
// findNextSquare(121) --> returns 144 | |
// findNextSquare(625) --> returns 676 |
This file contains hidden or 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
// 12/22/2015 | |
// You have an array of numbers 1 through 10 (JS: 1 through 10 or less). The array needs to be formatted correctly for the person | |
reading the countdown of a spaceship launch. | |
// Unfortunately, the person reading the countdown only knows how to read strings. After the array is sorted correctly make | |
sure it's in a format he can understand. | |
// Between each number should be a space and after the final number (1) should be the word 'liftoff!' | |
// Example: | |
// Given |
This file contains hidden or 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
// 12/23/2015 | |
// Write a function to test whether a given input is a valid email address. | |
// For the purposes of this kata, here is what makes a valid email: | |
// At least one letter character at the beginning >>>>> | |
// All characters between the first character and the @ (if any) | |
// must be letters, numbers, or underscores >>>>> | |
// There must be an @ character (after the points listed just now) >>>>> | |
// After the @ character, there must be at least one word character (letter, |
OlderNewer