Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5502
}
53 changes: 26 additions & 27 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,79 +3,78 @@
*******************************************/
// Write code that prints out to the console the index of the character “j” in

const string1 = "My favorite dessert is jello";

// Your code here...


const string1 = 'My favorite dessert is jello'

console.log(string1.indexOf('j'))

/*******************************************
Iteration 2 | Concatenate Characters
*******************************************/
// Make a new string with the text "COOL" by using only the characters available in the provided string and the bracket notation

const string2 = "ABCDEFGHJKLO";
const string2 = 'ABCDEFGHJKLO'

// Your code here...



const newString =
string2[string2.indexOf('C')] +
string2[string2.indexOf('O')] +
string2[string2.indexOf('O')] +
string2[string2.indexOf('L')]
console.log(newString)

/*****************************************************
Iteration 3 | Repeat a String and Concatenate
*****************************************************/
// Using the method .repeat() and the provided string, print out the text "NaNaNaNa Batman!" in the console.

const string3 = "Na";
const string3 = 'Na'

// Your code here...



console.log(string3.repeat(4), ' Batman!')

/*******************************************
Iteration 4 | Fruite Slice
*******************************************/
// Using the string method .slice(), access and print to the console the name of your favorite fruit from a given string

const fruit = "banana apple mango orange lemon kiwi watermelon grapes pear pineapple";
const fruit =
'banana apple mango orange lemon kiwi watermelon grapes pear pineapple'

// Your code here...



const favFruit = fruit.slice(7, 13)
console.log(favFruit)
/***************************************************
Iteration 5 | Check If Strings Include a Word
***************************************************/
// Using the string method .include(), check if the below strings with funny newspaper headlines include the word "oxygen".
// If a string includes the word "oxygen" print to the console message "The string includes the word 'oxygen'",
// else print the message "The string does not include the word 'oxygen'".

const funnyHeadline1 = "Breathing oxygen linked to staying alive";
const funnyHeadline2 = "Students Cook & Serve Grandparents";

const funnyHeadline1 = 'Breathing oxygen linked to staying alive'
const funnyHeadline2 = 'Students Cook & Serve Grandparents'

// Check the first headline
// Your code here ...

funnyHeadline1.includes('oxygen')
? console.log("The string include the word 'oxygen'")
: console.log("The string does not include the word 'oxygen'")

// Check the second headline
// Your code here ...


funnyHeadline2.includes('oxygen')
? console.log("The string include the word 'oxygen'")
: console.log("The string does not include the word 'oxygen'")

/*******************************************
Iteration 6 | String Length
*******************************************/
// Using console.log() print to the console the length of the string and the last character in the string.

const string4 = "zEAWrTC9EgtxmK9w1";

const string4 = 'zEAWrTC9EgtxmK9w1'

// a) Print the string length
// Your code here ...

console.log(string4.length)

// b) Print the last character in the string
// Your code here ...
console.log(string4[string4.length - 1])