1. const canJump = (nums) => {
    2. let n = nums.length;
    3. let rightmost = 0;
    4. for (let i = 0; i < n; ++i) {
    5. if (i <= rightmost) {
    6. rightmost = Math.max(rightmost, i + nums[i]);
    7. if (rightmost >= n - 1) {
    8. return true;
    9. }
    10. }
    11. }
    12. return false;
    13. }