add hints to exercises
This commit is contained in:
parent
cf1759dc97
commit
dd17d8ac8b
7 changed files with 43 additions and 4 deletions
|
@ -45,4 +45,6 @@ var helloWorld = function() {
|
|||
}
|
||||
|
||||
module.exports = helloWorld
|
||||
```
|
||||
```
|
||||
|
||||
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!
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
|
||||
## 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.
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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.
|
||||
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.
|
||||
|
|
|
@ -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
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
## 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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue