<aside> 💡 https://www.github.com/100xdevs-cohort-2/assignments
</aside>
<aside> 💡 This is NOT a function, since you’re not calling it. (Note - no parenthesis around the “function”)
</aside>
// Length
function getLength(str) {
console.log("Original String:", str);
console.log("Length:", str.length);
}
getLength("Hello World");
// 11
// indexOf
function findIndexOf(str, target) {
console.log("Original String:", str);
console.log("Index:", str.indexOf(target));
}
findIndexOf("Hello World", "World");
// 6
// lastIndexOf
function findLastIndexOf(str, target) {
console.log("Original String:", str);
console.log("Index:", str.lastIndexOf(target));
}
findLastIndexOf("Hello World World", "World");
// 12
<aside> 💡 It DOES NOT include the last parameter, it gives you out the value before the last parameter
</aside>
It gives you the string from the <parameter 1> index, to <parameter 2> - 1 index
function getSlice(str, start, end) {
console.log("Original String:", str);
console.log("After slice:", str.slice(start, end));
}
getSlice("Hello World", 2, 7);
// llo W