Skip to content

Commit bbf6e04

Browse files
Initial Commit
1 parent 78d9e96 commit bbf6e04

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

index.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Exercise</title>
5+
<script src="js/exercises.js"></script>
6+
</head>
7+
<body>
8+
<h1>Exercises</h1>
9+
10+
</body>
11+
</html>

js/exercises.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
window.onload = main;
2+
3+
4+
function main(){
5+
//Calling the end function
6+
console.log("Testing end function: " + end("Bastian", "n"));
7+
8+
}
9+
10+
/**
11+
FreeCodeCamp Bonfire: Confirm The Ending
12+
A function that will look if a string ends with the following target.
13+
14+
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr
15+
@parameters
16+
str - Main string that will be the string we look through
17+
target - The target value we want to find at str's ending
18+
19+
@returns - bool
20+
*/
21+
function end(str, target) {
22+
// "Never give up and good luck will find you."
23+
// -- Falcor
24+
25+
//making a sub string out of str that is at the end of the string and compare it with the target.
26+
if(str.substr(str.length - target.length, target.length) == target){
27+
return true;
28+
}
29+
return false;
30+
}

0 commit comments

Comments
 (0)