From dd17d8ac8b2e49478d96bb317ffc0d7505b2ea13 Mon Sep 17 00:00:00 2001 From: Cody Loyd Date: Tue, 24 Oct 2017 15:10:20 -0500 Subject: [PATCH] add hints to exercises --- helloWorld/README.md | 4 +++- leapYears/README.md | 3 +++ removeFromArray/README.md | 10 +++++++++- repeatString/README.md | 9 +++++++++ reverseString/README.md | 8 +++++++- sumAll/README.md | 11 ++++++++++- tempConversion/README.md | 2 ++ 7 files changed, 43 insertions(+), 4 deletions(-) diff --git a/helloWorld/README.md b/helloWorld/README.md index f9a9808..2a51d18 100644 --- a/helloWorld/README.md +++ b/helloWorld/README.md @@ -45,4 +45,6 @@ var helloWorld = function() { } module.exports = helloWorld -``` \ No newline at end of file +``` + +For the most part we've set up these tests in such a way that you only have to write the code being tested. You should not have to worry about importing or exporting anything at this stage.. so just work around that bit of the code and write what it takes to make them pass! diff --git a/leapYears/README.md b/leapYears/README.md index 33e6922..30bf967 100644 --- a/leapYears/README.md +++ b/leapYears/README.md @@ -9,3 +9,6 @@ leapYears(2000) // is a leap year: returns true leapYears(1985) // is not a leap year: returns false ``` + +## hints +- use an `if` statement and `&&` to make sure all the conditions are met properly diff --git a/removeFromArray/README.md b/removeFromArray/README.md index b392417..9b3ebc0 100644 --- a/removeFromArray/README.md +++ b/removeFromArray/README.md @@ -4,4 +4,12 @@ Implement a function that takes an array and some other arguments then removes t ```javascript remove([1,2,3,4], 3) // should remove 3 and return [1,2,4] -``` \ No newline at end of file +``` + + + +## hints +the first test on this one is fairly easy, but there are a few things to think about(or google) here for the later tests: +- how to remove a single element from an array +- how to deal with multiple optional arguments in a javascript function + - [Check this link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments). Scroll down to the bit about `Array.from` or the spread operator. diff --git a/repeatString/README.md b/repeatString/README.md index c83d3c0..70823e6 100644 --- a/repeatString/README.md +++ b/repeatString/README.md @@ -8,3 +8,12 @@ repeatString('hey', 3) // returns 'heyheyhey' + + + +## hints + +You're going to want to use a loop for this one. + +Create a variable to hold the string you're going to return, create a loop that repeats the given number of times and add the given string to the result on each loop. + diff --git a/reverseString/README.md b/reverseString/README.md index e413dac..dfb00de 100644 --- a/reverseString/README.md +++ b/reverseString/README.md @@ -6,4 +6,10 @@ Pretty simple, write a function called `reverseString` that returns it's input, reverseString('hello there') // returns 'ereht olleh' ``` -You will notice in this exercise that there are multiple tests, after making the first one pass, enable the others one by one by deleting the `x` in front of the `it()` function. \ No newline at end of file +You will notice in this exercise that there are multiple tests, after making the first one pass, enable the others one by one by deleting the `x` in front of the `it()` function. + + + + +## hints +Strings in JavaScript cannot be reversed directly so you're going to have to split it into something else first.. do the reversal and then join it back together into a string. diff --git a/sumAll/README.md b/sumAll/README.md index 813baa4..f399eda 100644 --- a/sumAll/README.md +++ b/sumAll/README.md @@ -4,4 +4,13 @@ Implement a function that takes 2 integers and returns the sum of every number b ```javascript sumAll(1, 4) // returns the sum of 1 + 2 + 3 + 4 which is 10 -``` \ No newline at end of file +``` + + +## hints + +Think about how you would do this on pen and paper and then how you might translate that process into code: +- create a variable to hold the final sum +- loop through the given numbers ([link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration)) +- on each iteration add the number to the sum +- return the sum after finishing the loop diff --git a/tempConversion/README.md b/tempConversion/README.md index 334b302..959d029 100644 --- a/tempConversion/README.md +++ b/tempConversion/README.md @@ -10,3 +10,5 @@ ctof(0) // celsius to fahrenheit, should return 32 ``` +## hints +The math here is fairly straightforward.. just google the formula and implement it in the code