1
00:00:00,540 --> 00:00:03,570
Let me show you how I'm going to solve this challenge.

2
00:00:03,840 --> 00:00:06,750
There are so many ways to go by this weather.

3
00:00:06,750 --> 00:00:13,380
You can go in a long way or a short way, but by the end, all what we need is that we have achieved

4
00:00:13,380 --> 00:00:14,160
our goal.

5
00:00:14,190 --> 00:00:15,690
That is programming for you.

6
00:00:15,810 --> 00:00:21,090
So let me count down here and now let me read the question step by step.

7
00:00:21,300 --> 00:00:26,380
One Create a function to check if it start with a string.

8
00:00:26,400 --> 00:00:31,200
So the first point, let me know the name of my function.

9
00:00:31,500 --> 00:00:32,250
That is it.

10
00:00:32,250 --> 00:00:37,380
So the name or the name of my function I'm going to use is called Start With.

11
00:00:37,590 --> 00:00:46,590
So I'm going to use normal function, start with and then maybe I can add function to it.

12
00:00:46,620 --> 00:00:49,530
Now here you go and here we go.

13
00:00:49,530 --> 00:00:53,310
So let me comment here and call this one as solution.

14
00:00:54,930 --> 00:00:56,850
So I'm done with the first one.

15
00:00:57,180 --> 00:01:01,500
The second one says that the function should take two arguments.

16
00:01:01,530 --> 00:01:07,020
The first argument is the string, and the second argument is a string to check.

17
00:01:07,110 --> 00:01:14,250
Remember, when we say argument, I always repeat This is a values you pass in or call the function

18
00:01:14,250 --> 00:01:17,340
and the parameters are values you pass into the function.

19
00:01:17,340 --> 00:01:18,900
When is it being called?

20
00:01:19,110 --> 00:01:25,980
So when I when I hear argument, it means and pass in parameters and it first prioritizes what the string.

21
00:01:25,980 --> 00:01:29,520
So I can label this one as my string.

22
00:01:30,030 --> 00:01:36,150
And then the second argument is a string to check so I can give it as a start.

23
00:01:37,380 --> 00:01:38,280
Or check.

24
00:01:38,730 --> 00:01:46,800
So inside the function, first of all, we are going to check if indeed is a string, okay?

25
00:01:46,950 --> 00:01:48,180
If indeed is a string.

26
00:01:48,210 --> 00:01:51,510
If it's not a string, then we can retain that place.

27
00:01:51,510 --> 00:01:52,470
Provide a string.

28
00:01:52,470 --> 00:01:52,970
Right.

29
00:01:52,980 --> 00:01:53,930
So let's see.

30
00:01:53,940 --> 00:01:56,640
Point number three, the function should return.

31
00:01:56,640 --> 00:01:57,300
True.

32
00:01:57,300 --> 00:02:03,510
If the if the string start with the string that we are going to pass in and otherwise false.

33
00:02:03,600 --> 00:02:05,940
So check.

34
00:02:06,790 --> 00:02:09,130
Eve the string.

35
00:02:11,790 --> 00:02:13,350
The string start with.

36
00:02:15,240 --> 00:02:16,260
With a string.

37
00:02:17,580 --> 00:02:19,220
Or indeed is a string.

38
00:02:19,230 --> 00:02:19,710
Perfect.

39
00:02:19,710 --> 00:02:21,330
So here if.

40
00:02:22,110 --> 00:02:26,070
This string I'm going to pass in as my agreement on that.

41
00:02:26,070 --> 00:02:28,290
I have a method called start with.

42
00:02:29,290 --> 00:02:35,290
And it starts with what the texts or the text I want to find inside that that text.

43
00:02:35,290 --> 00:02:42,280
So I'll put that here as starts, meaning my text to search for as my start.

44
00:02:42,700 --> 00:02:47,920
So after that then my carry base is perfect.

45
00:02:47,920 --> 00:02:53,200
So if it is true, then I'm going to return true here as it says.

46
00:02:53,770 --> 00:02:55,450
Return true.

47
00:02:56,990 --> 00:03:03,500
Otherwise, if it doesn't start with this or this one means that string does not start with a certain

48
00:03:03,500 --> 00:03:06,320
text or the agreement we pass in.

49
00:03:06,500 --> 00:03:12,050
So down here I'm going to return or I can provide errors here.

50
00:03:12,320 --> 00:03:19,110
Let's see errors here like that so I can remove the errors and then I can return.

51
00:03:19,130 --> 00:03:21,080
Down here is the same thing.

52
00:03:21,260 --> 00:03:22,520
So start.

53
00:03:22,520 --> 00:03:24,900
Let's say string.

54
00:03:25,010 --> 00:03:26,170
Let me ask a message.

55
00:03:26,180 --> 00:03:28,850
String does not.

56
00:03:29,540 --> 00:03:32,720
Does not start with.

57
00:03:33,380 --> 00:03:34,760
Then I can contact.

58
00:03:34,790 --> 00:03:35,070
Okay.

59
00:03:35,090 --> 00:03:37,250
So I can use the template right here.

60
00:03:37,280 --> 00:03:40,580
Because now we are writing I mean modern JavaScript here.

61
00:03:40,760 --> 00:03:44,000
So here my template right here.

62
00:03:44,060 --> 00:03:46,810
Start with I want to inject dynamic value.

63
00:03:46,820 --> 00:03:48,620
So start.

64
00:03:49,310 --> 00:03:50,510
And that is it.

65
00:03:50,540 --> 00:03:57,070
So lastly, let's call the function down here called Invoke and now start with function.

66
00:03:57,080 --> 00:03:59,900
Then I'll pass in academy.

67
00:04:00,990 --> 00:04:04,260
They don't search for less litter a.

68
00:04:05,060 --> 00:04:11,510
So let me assign the result coming back after cognitive function into a variable called response or

69
00:04:11,510 --> 00:04:12,800
rest or result.

70
00:04:14,000 --> 00:04:20,480
So let me consider that log the resort and let's see where I get undefined while the problem.

71
00:04:21,670 --> 00:04:22,300
Oh, sorry.

72
00:04:22,510 --> 00:04:23,870
Line number two, eight and nine.

73
00:04:23,890 --> 00:04:24,610
I didn't return.

74
00:04:24,610 --> 00:04:24,840
True.

75
00:04:24,880 --> 00:04:25,150
Maybe.

76
00:04:25,150 --> 00:04:26,770
I don't know why it has been removed.

77
00:04:26,770 --> 00:04:26,890
So.

78
00:04:26,890 --> 00:04:27,210
Yeah.

79
00:04:27,220 --> 00:04:28,030
Return true.

80
00:04:28,180 --> 00:04:35,920
The string is this one I pass in here and the one I'm searching for is the stars is this one.

81
00:04:35,920 --> 00:04:39,940
So there is a inside the string I pass in here.

82
00:04:39,970 --> 00:04:41,920
That's why I go through.

83
00:04:42,190 --> 00:04:49,540
So if I pass in, let's say here, I pass in, let's say seven.

84
00:04:50,200 --> 00:04:59,140
We see that I got this message that string does not start with seven, meaning I'm wrong so I can pass

85
00:04:59,140 --> 00:05:02,380
in, let's say Z or let's say Z.

86
00:05:02,620 --> 00:05:11,020
Again, I go the same message that string does not start with Z, meaning our function is working perfectly.

