Guest User

Untitled

a guest
Jul 18th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. const canJump = nums => {
  2. let maxIndex = 0;
  3.  
  4. for (let index = 0; index < nums.length; index++) {
  5. if (maxIndex >= index) maxIndex = Math.max(maxIndex, nums[index] + index);
  6. else return false;
  7. }
  8.  
  9. return maxIndex >= nums.length - 1;
  10. };
Add Comment
Please, Sign In to add comment