File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed
Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments