Published
Edited
Mar 25, 2019
Insert cell
Insert cell
Insert cell
function rotLeft(a, d) {
// First we cut the array from the right of the given number,
// Then we slice it again from the left and we build the new array.
return [...a.slice(d), ...a.slice(0, d)];

}
Insert cell
rotLeft([1, 2, 3, 4, 5], 4)
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more