Arrays: Left Rotation

  • + 1 comment

    indeed, forgot that end goes through the end of a sequence, so here is my solution

    function rotLeft(a, d) {
        const index = d % a.length;
    
        return [...a.slice(index), ...a.slice(0, index)];
    }