Let me show you how I'm going to solve this particular challenge.
The first one is going to be pretty simple because the functions we take in, let's say a string and
then repeat it many times, meaning the number of repetitions is going to be fixed by the string we
pass in is going to be dynamic.
So solution number one.
Solution one let's go second.
Let's say KONST hasn't enough room here.
KONST Let me call it as repeat.
Repeat string.
And now it's eco to function parentheses, carry bases, retain the functions you take in a string str
and then on that, on the string I can use repeat, then I won't repeat, let's say five times or ten
times depending how you want it, or 20 times, let's say six times that is it.
So if I assign the result coming back from calling the function as repeat string or let me string g
here g so here I'll passing the string I want to repeat, let me encode as Node.js.
Node.js.
So let's check the result here.
You see, that has repeated many times.
Perfect.
So the next question is that here the next question is going to be improved upon this one for this one,
because if you pass in a fixed value here.
But the next challenge is that we are going to make this one also dynamic, and then you're going to
check if a is a pass in, let's say a string.
Let's say that for this function I didn't pass anything and see that when I check for the results,
you see that I get empty string and I don't want that.
I want to check if a user didn't provide in, let's say a string.
Instead I place the character must be less than zero.
Okay, good.
Much more than zero.
Yeah.
So that's how the that's how this I mean, the first challenge is sorry about so I can copy this one.
Okay.
And then come down here.
I solution too so here would name it as repeat string to that is it.
So inside here things are going to be changed.
So this function takes in what it says that the function should take to activate the string and a number.
So I'm going to pass in the number of times I want to repeat this.
So here I'll pass in second parameter here as num number and here return what.
Retain string, my string dots repeats repeat, then I'll pass in the number of times I want to repeat.
That is it.
But you.
You're going to improve a little bit.
So let's assign the result coming back as my answer is equal to repeat two, then I'll pass in.
First of all, let's say hello, then I won't repeat this 190 times.
So if I check my console for answer, we see that it has repeated I mean 90 times here, but let's say
I didn't provide anything.
Let's say zero empty string that I didn't get.
Let me check that I'm going to have empty string.
So let's check if I didn't provide if the length or character is a pass and it's less than zero.
So let's check.
Check if the number.
Of character is the let me say the the length.
Of this training.
Is less than or equal to.
Zero.
So.
So here, let's check.
So, Eve.
Remember, you talk about lamb.
Is that how crucial it is right now?
So let's say that.
Well, let's check for the number, not the string.
Sorry.
So then if the number is less than or equal to zero, then we can return.
Remember for written keyword, any time you use a return key word keyword and the condition parses is
going to exit the entire function.
So here we see that number.
Must be.
Greater than.
Zero.
I think check if the number so if the number.
So if the numbers are here how checking for the string if the number is less than zero.
So here.
Let's provide let's say, I mean, come has my strength.
And then if I provide this one, let me check let me check inside my console and see let me check for
the enzyme.
See that I get it as 90 times I can, let's say 9000 times.
Let me check with the function.
See that I have to click more before I can see the rest.
See that I repeat it 9000 times.
That's how function is crazy know in programming.
So let's say that I didn't provide.
I probably say zero here.
Let me check for the answer.
You see, that place number might be greater than zero.
So if I.
Let's see one.
You're going to repeat what all you want times.
So let's check for the answer and see that come.
I can repeat ten times.
Let's check.
Yes, that is it.