Published
Edited
Dec 4, 2018
Insert cell
Insert cell
ids.reduce((max, id, i, ids) => {
const longer = ids
.slice(i + 1)
.map(other => intersection(id, other))
.find(c => c.length > max.length)
return longer || max
}, '')
Insert cell
function intersection(s1, s2) {
const l1 = s1.split(''),
l2 = s2.split('')
return l1.filter((c, i) => c === l2[i]).join('')
}
Insert cell
Insert cell
Insert cell
Insert cell
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