Skip to content

Commit 903b731

Browse files
committed
lastIndexOf() function exercise
1 parent 90cadba commit 903b731

1 file changed

Lines changed: 35 additions & 31 deletions

File tree

‎Sprint-2/Prep/functions.js‎

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,51 @@
1-
console.log("In this exercise I will be learning different functions, and preactising them. ")
1+
console.log("In this exercise I will be learning different functions, and preactising them. ");
22

3-
let userName = "Matthew"
4-
let location = "Manchester"
5-
let favoriteFood = "Jollof rice"
3+
let userName = "Matthew";
4+
let location = "Manchester";
5+
let favoriteFood = "Jollof rice";
66

77
function myInfo(userName, location, favoriteFood) {
88
console.log(`My name is ${userName}` )
99
console.log(`I live in ${location}` )
1010
console.log(`My favorite food is ${favoriteFood}` )
11-
}
12-
myInfo(userName, location, favoriteFood)
11+
};
12+
myInfo(userName, location, favoriteFood);
1313

14-
sliceUserName = userName.slice(0, 4)
15-
console.log(`My friends love to call me ${sliceUserName}`)
14+
sliceUserName = userName.slice(0, 4);
15+
console.log(`My friends love to call me ${sliceUserName}`);
1616

17-
sliceLocation = location.lastIndexOf("h")
18-
console.log(sliceLocation)
17+
sliceLocation = location.lastIndexOf("h");
18+
console.log(sliceLocation);
1919

20-
const number1 = "50"
21-
const number2 = "100"
22-
const result = Number(number1) + Number(number2)
23-
console.log(result)
20+
const number1 = "50";
21+
const number2 = "100";
22+
const result = Number(number1) + Number(number2);
23+
console.log(result);
2424

25-
let hobby = "I love football and traveling"
26-
let moreHobby = hobby.replaceAll("football", "swiming").replaceAll("traveling", "hiking")
27-
console.log(moreHobby)
25+
let hobby = "I love football and traveling";
26+
let moreHobby = hobby.replaceAll("football", "swiming").replaceAll("traveling", "hiking");
27+
console.log(moreHobby);
2828

29-
const passion = hobby.substring(6, 15)
30-
console.log(passion)
29+
const passion = hobby.substring(6, 15);
30+
console.log(passion);
3131

32-
const luckyNumber = "7"
33-
const changeNumber = luckyNumber.padStart(5, "0")
34-
console.log(changeNumber)
32+
const luckyNumber = "7";
33+
const changeNumber = luckyNumber.padStart(5, "0");
34+
console.log(changeNumber);
3535

36-
const anotherNumber = luckyNumber.padEnd(5, "0")
37-
console.log(anotherNumber)
36+
const anotherNumber = luckyNumber.padEnd(5, "0");
37+
console.log(anotherNumber);
3838

39-
const carPrice = 30000.50
40-
const updatedCarPrice = Math.floor(carPrice)
41-
console.log(updatedCarPrice)
39+
const carPrice = 30000.50;
40+
const updatedCarPrice = Math.floor(carPrice);
41+
console.log(updatedCarPrice);
4242

43-
const addNumber = 20
44-
const addNumber2 = 30
45-
const addNumber3 = addNumber + addNumber2
43+
const addNumber = 20;
44+
const addNumber2 = 30;
45+
const addNumber3 = addNumber + addNumber2;
4646
const addNumberResult = Math.random() * addNumber3
47-
console.log(addNumberResult)
47+
console.log(addNumberResult);
48+
49+
const repeatedText = "one, two, three";
50+
const lastOnePosition = repeatedText.lastIndexOf("one");
51+
console.log(lastOnePosition);

0 commit comments

Comments
 (0)