// 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 // }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter