Published
Edited
Jun 21, 2020
Insert cell
Insert cell
array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
Insert cell
{
const result = []
for (let index = 0; index < array.length; index += 1) {
if (array[index] % 2 === 1) {
result.push(array[index])
}
}
return result
}
Insert cell
{
const result = []
for (let index = 0; index < array.length; index += 1) {
if (array[index] & 1) {
result.push(array[index])
}
}
return result
}
Insert cell
array.filter(item => item & 1)
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