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
Complete the given function growth that will calculate how many years until a town reaches a given population. The population will begin at a given start population. At the end of each year, the population will grow by a given percent, and then the population will change by a constant value called aug (inhabitants coming or leaving each year). Calculate how many years until it reaches the given goal population. | |
Note: Population should always be an integer, so always remove any decimal portion after each year. (Always round down) | |
Input Format: | |
The function will have 4 arguments | |
start - the initial population | |
percent - the percentage of population growth each year. (ex: 2 represents 2% growth) | |
aug - the constant number of inhabitants coming or leaving each year | |
goal - the population to meet or exceed |
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
Mutations | |
Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array. | |
For example, ["hello", "Hello"], should return true because all of the letters in the second string are present in the first, ignoring case. | |
The arguments ["hello", "hey"] should return false because the string "hello" does not contain a "y". | |
Lastly, ["Alien", "line"], should return true because all of the letters in "line" are present in "Alien". | |
Remember to use Read-Search-Ask if you get stuck. Write your own code. |
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
Slasher Flick | |
Return the remaining elements of an array after chopping off n elements from the head. | |
The head means the beginning of the array, or the zeroth index. | |
Remember to use Read-Search-Ask if you get stuck. Write your own code. | |
using splice |
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
Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a two-dimensional array. | |
Remember to use Read-Search-Ask if you get stuck. Write your own code. | |
Here are some helpful links: | |
Array.push() | |
Array.slice() | |
function chunkArrayInGroups(arr, size) { |
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
Truncate a string | |
Truncate a string (first argument) if it is longer than the given maximum string length (second argument). Return the truncated string with a ... ending. | |
Note that inserting the three dots to the end will add to the string length. | |
However, if the given maximum string length num is less than or equal to 3, then the addition of the three dots does not add to the string length in determining the truncated string. | |
Remember to use Read-Search-Ask if you get stuck. Write your own code. | |
Here are some helpful links: |
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
Repeat a string repeat a string | |
Repeat a given string (first argument) num times (second argument). Return an empty string if num is a negative number. | |
Remember to use Read-Search-Ask if you get stuck. Write your own code. | |
Here are some helpful links: | |
Global String Object | |
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
Repeat a string repeat a string | |
Repeat a given string (first argument) num times (second argument). Return an empty string if num is a negative number. | |
Remember to use Read-Search-Ask if you get stuck. Write your own code. | |
Here are some helpful links: | |
Global String Object |
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
Check if a string (first argument, str) ends with the given target string (second argument, target). | |
Remember to use Read-Search-Ask if you get stuck. Write your own code. | |
Here are some helpful links: | |
String.substr() | |
function confirmEnding(str, target) { | |
// "Never give up and good luck will find you." |
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
Return Largest Numbers in Arrays | |
Return an array consisting of the largest number from each provided sub-array. For simplicity, the provided array will contain exactly 4 sub-arrays. | |
Remember, you can iterate through an array with a simple for loop, and access each member with array syntax arr[i]. | |
Remember to use Read-Search-Ask if you get stuck. Write your own code. | |
function largestOfFour(arr) { | |
for(var i=0 ; i < arr.length; i++) { | |
arr[i].sort(function(a,b) { |
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
Return the provided string with the first letter of each word capitalized. Make sure the rest of the word is in lower case. | |
For the purpose of this exercise, you should also capitalize connecting words like "the" and "of". | |
Remember to use Read-Search-Ask if you get stuck. Write your own code. | |
function titleCase(str) { | |
var arr = str.split(' '); | |
var arr1 = []; | |