1
00:00:02,530 --> 00:00:06,400
Let me show you how I'm going to solve this particular challenge.

2
00:00:06,490 --> 00:00:12,640
The first one is going to be pretty simple because the functions we take in, let's say a string and

3
00:00:12,640 --> 00:00:18,760
then repeat it many times, meaning the number of repetitions is going to be fixed by the string we

4
00:00:18,760 --> 00:00:21,190
pass in is going to be dynamic.

5
00:00:21,430 --> 00:00:23,350
So solution number one.

6
00:00:24,080 --> 00:00:27,770
Solution one let's go second.

7
00:00:27,800 --> 00:00:31,760
Let's say KONST hasn't enough room here.

8
00:00:32,659 --> 00:00:36,980
KONST Let me call it as repeat.

9
00:00:38,080 --> 00:00:39,640
Repeat string.

10
00:00:40,970 --> 00:00:52,130
And now it's eco to function parentheses, carry bases, retain the functions you take in a string str

11
00:00:52,160 --> 00:00:59,180
and then on that, on the string I can use repeat, then I won't repeat, let's say five times or ten

12
00:00:59,180 --> 00:01:04,700
times depending how you want it, or 20 times, let's say six times that is it.

13
00:01:04,700 --> 00:01:15,230
So if I assign the result coming back from calling the function as repeat string or let me string g

14
00:01:15,230 --> 00:01:21,770
here g so here I'll passing the string I want to repeat, let me encode as Node.js.

15
00:01:23,340 --> 00:01:24,240
Node.js.

16
00:01:24,480 --> 00:01:28,170
So let's check the result here.

17
00:01:29,350 --> 00:01:31,920
You see, that has repeated many times.

18
00:01:32,160 --> 00:01:32,850
Perfect.

19
00:01:33,000 --> 00:01:41,790
So the next question is that here the next question is going to be improved upon this one for this one,

20
00:01:41,810 --> 00:01:44,700
because if you pass in a fixed value here.

21
00:01:44,910 --> 00:01:50,790
But the next challenge is that we are going to make this one also dynamic, and then you're going to

22
00:01:50,790 --> 00:01:53,570
check if a is a pass in, let's say a string.

23
00:01:53,580 --> 00:01:59,730
Let's say that for this function I didn't pass anything and see that when I check for the results,

24
00:02:00,450 --> 00:02:03,150
you see that I get empty string and I don't want that.

25
00:02:03,150 --> 00:02:07,600
I want to check if a user didn't provide in, let's say a string.

26
00:02:07,600 --> 00:02:11,220
Instead I place the character must be less than zero.

27
00:02:11,970 --> 00:02:13,460
Okay, good.

28
00:02:13,470 --> 00:02:15,060
Much more than zero.

29
00:02:15,060 --> 00:02:15,540
Yeah.

30
00:02:15,630 --> 00:02:23,190
So that's how the that's how this I mean, the first challenge is sorry about so I can copy this one.

31
00:02:24,820 --> 00:02:25,890
Okay.

32
00:02:25,900 --> 00:02:27,280
And then come down here.

33
00:02:27,310 --> 00:02:33,910
I solution too so here would name it as repeat string to that is it.

34
00:02:34,060 --> 00:02:36,780
So inside here things are going to be changed.

35
00:02:36,790 --> 00:02:44,070
So this function takes in what it says that the function should take to activate the string and a number.

36
00:02:44,080 --> 00:02:48,340
So I'm going to pass in the number of times I want to repeat this.

37
00:02:48,580 --> 00:02:55,690
So here I'll pass in second parameter here as num number and here return what.

38
00:02:56,900 --> 00:03:08,120
Retain string, my string dots repeats repeat, then I'll pass in the number of times I want to repeat.

39
00:03:08,420 --> 00:03:09,110
That is it.

40
00:03:10,490 --> 00:03:11,020
That is it.

41
00:03:11,030 --> 00:03:11,930
But you.

42
00:03:11,960 --> 00:03:13,450
You're going to improve a little bit.

43
00:03:13,460 --> 00:03:20,900
So let's assign the result coming back as my answer is equal to repeat two, then I'll pass in.

44
00:03:20,930 --> 00:03:26,150
First of all, let's say hello, then I won't repeat this 190 times.

45
00:03:26,510 --> 00:03:34,010
So if I check my console for answer, we see that it has repeated I mean 90 times here, but let's say

46
00:03:34,010 --> 00:03:35,050
I didn't provide anything.

47
00:03:35,120 --> 00:03:37,550
Let's say zero empty string that I didn't get.

48
00:03:37,550 --> 00:03:40,310
Let me check that I'm going to have empty string.

49
00:03:40,310 --> 00:03:47,570
So let's check if I didn't provide if the length or character is a pass and it's less than zero.

50
00:03:47,810 --> 00:03:49,130
So let's check.

51
00:03:49,820 --> 00:03:54,200
Check if the number.

52
00:03:55,960 --> 00:03:59,590
Of character is the let me say the the length.

53
00:04:01,360 --> 00:04:02,740
Of this training.

54
00:04:06,160 --> 00:04:10,930
Is less than or equal to.

55
00:04:13,500 --> 00:04:14,070
Zero.

56
00:04:14,220 --> 00:04:14,790
So.

57
00:04:14,790 --> 00:04:15,690
So here, let's check.

58
00:04:15,700 --> 00:04:16,390
So, Eve.

59
00:04:16,410 --> 00:04:17,959
Remember, you talk about lamb.

60
00:04:18,000 --> 00:04:19,860
Is that how crucial it is right now?

61
00:04:20,130 --> 00:04:21,899
So let's say that.

62
00:04:22,500 --> 00:04:25,410
Well, let's check for the number, not the string.

63
00:04:25,410 --> 00:04:25,740
Sorry.

64
00:04:25,740 --> 00:04:31,560
So then if the number is less than or equal to zero, then we can return.

65
00:04:31,560 --> 00:04:37,820
Remember for written keyword, any time you use a return key word keyword and the condition parses is

66
00:04:37,830 --> 00:04:41,040
going to exit the entire function.

67
00:04:41,040 --> 00:04:43,260
So here we see that number.

68
00:04:44,960 --> 00:04:46,610
Must be.

69
00:04:48,410 --> 00:04:49,340
Greater than.

70
00:04:50,000 --> 00:04:51,680
Greater than.

71
00:04:52,710 --> 00:04:53,310
Zero.

72
00:04:54,120 --> 00:04:57,030
I think check if the number so if the number.

73
00:04:57,810 --> 00:05:03,240
So if the numbers are here how checking for the string if the number is less than zero.

74
00:05:03,240 --> 00:05:04,140
So here.

75
00:05:05,820 --> 00:05:11,400
Let's provide let's say, I mean, come has my strength.

76
00:05:11,400 --> 00:05:17,700
And then if I provide this one, let me check let me check inside my console and see let me check for

77
00:05:17,700 --> 00:05:18,320
the enzyme.

78
00:05:18,330 --> 00:05:23,970
See that I get it as 90 times I can, let's say 9000 times.

79
00:05:24,210 --> 00:05:26,790
Let me check with the function.

80
00:05:26,790 --> 00:05:29,460
See that I have to click more before I can see the rest.

81
00:05:29,460 --> 00:05:32,790
See that I repeat it 9000 times.

82
00:05:32,820 --> 00:05:35,280
That's how function is crazy know in programming.

83
00:05:35,550 --> 00:05:38,010
So let's say that I didn't provide.

84
00:05:38,010 --> 00:05:39,480
I probably say zero here.

85
00:05:40,710 --> 00:05:42,150
Let me check for the answer.

86
00:05:42,180 --> 00:05:45,090
You see, that place number might be greater than zero.

87
00:05:45,300 --> 00:05:46,290
So if I.

88
00:05:46,320 --> 00:05:47,370
Let's see one.

89
00:05:48,270 --> 00:05:51,050
You're going to repeat what all you want times.

90
00:05:51,060 --> 00:05:54,220
So let's check for the answer and see that come.

91
00:05:54,240 --> 00:05:56,610
I can repeat ten times.

92
00:05:57,370 --> 00:05:58,120
Let's check.

93
00:05:58,240 --> 00:05:59,920
Yes, that is it.

