So it's now time for you to start writing some of your own Javascript functions.
So I've written a problem set with three different problems.
Each one you'll have to write your own javascript function.
So I'm going to introduce all three problems and then in the next video we'll have solutions.
So the first one is called is even.
So you'll need to write a function called is even which takes a single argument which is a number and
it returns true if the number is even and false if it's not.
So there's a few examples is even of four returns true is even if 21 returns false is even a 68 is true
3 3 3 is false.
If you need to jog your memory on how you determine if a number is even you can watch some of the previous
videos where we talked about modulo.
Next up is a function called factorial.
So most of you probably don't remember what factorial is.
I think we talked about it like once in my high school math class.
Basically you take a number like four and factorial is written with an exclamation point often.
So for factorial is equal to 4 times 3 times 2 times 1.
So that gives us 24 6 factorial is six times five times four times three times 2 times 1.
So basically you're going to write a function that takes a number and multiply that number by every
integer below that between that number and 1.
So there's one small caveat which is zero factorial is 1.
So to write this function in need to have a variable that you're constantly multiplying by smaller and
smaller numbers so you multiply by four then three and then two and then one and you'll stop.
When you multiply by 1.
So you can see a few examples here.
Factorial of five is five times four times three times two times one which is a 120 factorial of two
is just two factorial of 10.
Is this massive number and factorial of zero.
Remember it needs to return 1.
So the last one here is a little bit different.
It's called Khabab to snake.
So if you recall there are different ways of writing strings different cases.
There's snake case where we use underscores like you see here.
Hello underscore world.
There's Khabab case where we use dashes haloed dash world.
So you're going to write a function called Khabab to snake which takes a single string argument that
is going to be Khabab case.
So it uses dashes between words and your job is to replace all those dashes with underscores to make
it snake case.
So in order to do that you may need to research a little bit about how you can replace characters in
a string.
So it's definitely intentional that this one is last in the problems that you may need to do a little
bit of research.
Do some googling figure out how you can replace all of a specific character in a string with another
specific character so you can see some sample input and output.
Hello Dasch world.
When you pass it into Khabab to snake should return Hello underscore world.
And one key point about all these exercises.
No contact logs.
These are all returned statements.
OK so in the next video we'll go over some solutions.