-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathincludes.js
34 lines (30 loc) · 1.33 KB
/
includes.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
"use strict";
// TOPIC /////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Array Method: .includes()
//
// SYNTAX ////////////////////////////////////////////////////////////////////////////////////////////////////
//
// string.includes(word)
// string.includes(word, OPTIONAL:where to begin looking at position)
//
// SUMMARY ///////////////////////////////////////////////////////////////////////////////////////////////////
//
// • includes() method determines wwhere one string may be found within another string.
// • includes() returns either true or false.
//
// EXAMPLES //////////////////////////////////////////////////////////////////////////////////////////////////
//
// EXAMPLE 1: Does the given string contain the entry "dog"
//
// RESOURCES /////////////////////////////////////////////////////////////////////////////////////////////////
//
//
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// EXAMPLE 1: Doe the given string include the entry "dog"?
let mySentence = "The cat and the dog ran up the hill";
function sentenceChecker(string, word) {
console.log(`The word "${word}" ${string.includes(word) ? "is" : "is not"} in the sentence`);
}
sentenceChecker(mySentence, "dog");