Public
Edited
Oct 18, 2023
Insert cell
Insert cell
Insert cell
valid = ['123456', '234567', '345678', '456789'];
Insert cell
invalid = ['098765', '987654', '876543', '654321']
Insert cell
Insert cell
Insert cell
Insert cell
toVoid('123456')
Insert cell
invalid
Insert cell
valid
Insert cell
// to valid

function toValid(value) {
let index = invalid.indexOf(value);

if (index !== -1) {
invalid.splice(index, 1); // Remove the value from the voided array
valid.push(value); // Add the value to the valid array
console.log(`Moved "${value}" from voided to valid.`);
} else {
console.log(`"${value}" not found in voided.`);
}
}
Insert cell
toValid('098765')
Insert cell
valid
Insert cell
invalid
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