Skip to content
Open
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
42 changes: 28 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

const string1 = "My favorite dessert is jello";

// Your code here...
const charPosition = string1.indexOf("j");

console.log(charPosition);



Expand All @@ -17,7 +19,9 @@ const string1 = "My favorite dessert is jello";

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);



Expand All @@ -29,19 +33,25 @@ const string2 = "ABCDEFGHJKLO";

const string3 = "Na";

// Your code here...
const stringRepeat = string3.repeat(4);

const batmanName = "Batman";

console.log(`${stringRepeat} ${batmanName}!`);




/*******************************************
Iteration 4 | Fruite Slice
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";

// Your code here...
const myFavouriteFruit = fruit.slice(fruit.indexOf("pear"), fruit.indexOf("pear") + "pear".length);

console.log(myFavouriteFruit);



Expand All @@ -56,26 +66,30 @@ const funnyHeadline1 = "Breathing oxygen linked to staying alive";
const funnyHeadline2 = "Students Cook & Serve Grandparents";


// Check the first headline
// Your code here ...
if (funnyHeadline1.includes("oxygen")) {
console.log("The string includes the word 'oxygen'");
} else {
console.log("The string does not include the word 'oxygen'");
};


// Check the second headline
// Your code here ...
if (funnyHeadline2.includes("oxygen")) {
console.log("The string includes the word 'oxygen'");
} else {
console.log("The string does not include the word 'oxygen'");
};



/*******************************************
Iteration 6 | String Length
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";


// 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]);