-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathendsWith.js
47 lines (37 loc) · 1.5 KB
/
endsWith.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"use strict";
// TOPIC /////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Array Method: .endsWith()
//
// SYNTAX ////////////////////////////////////////////////////////////////////////////////////////////////////
//
// string.endsWith('string');
//
// SUMMARY ///////////////////////////////////////////////////////////////////////////////////////////////////
//
// • .endsWith() methods determines whether a string ends with the characters of a specified string.
// • .endsWith() will return either TRUE or FALSE.
//
// EXAMPLES //////////////////////////////////////////////////////////////////////////////////////////////////
//
// EXAMPLE 1:
//
// RESOURCES /////////////////////////////////////////////////////////////////////////////////////////////////
//
//
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// EXAMPLE 1: Determine if a string ends with an included word.
const myString = "This is a test";
function doesItEndWith(string, wordToCheck) {
const checkTheString = string.endsWith(wordToCheck);
console.log(checkTheString);
}
doesItEndWith(myString, "test"); // true
// EXAMPLE 2:
const myString2 = "This is another test";
function DoesNotEndWith(string, wordToCheck) {
const checkTheString = string.endsWith(wordToCheck);
console.log(checkTheString);
}
DoesNotEndWith(myString2, "another"); // false