code-wars & FCC[1]

PHOTO EMBED

Thu Apr 06 2023 09:59:14 GMT+0000 (Coordinated Universal Time)

Saved by @AudibleJello #undefined

// Complete the solution so that it returns true if the first argument(string) passed in ends with the nd argument (also a string).
2
// https://www.codewars.com/kata/1f2d1cafcc0f5c0007d/train/javascript
3
// Test: Test.assertEquals(solution('abcde', 'cde'), true)
4
// Test.assertEquals(solution('abcde', 'abc'), false)
5
​

// function solution(str, ending){
7
//   for(i = -1; i >= -(ending.length); i--) {

//   if(str[str.length + i] === ending[ending.length + i]){
9
//     var match = str[str.length + i] === ending[ending.length + i]

//   }    

//   }

//   return match

// }

​
content_copyCOPY

https://codepen.io/AudibleJello/pen/PoBvmby