Files
codewars/jump/index.js
2019-11-14 10:21:53 +01:00

11 lines
283 B
JavaScript

// https://www.codewars.com/kata/594fae1a0462da7beb000046
const canJump = (arr, pos = 0) => {
if (pos >= arr.length) return true;
if (pos === arr.length - 1) return false;
for (let i = arr[pos]; i > 0; --i) {
if (canJump(arr, pos + i)) return true;
}
return false;
};