finding an object with reduce
a small array-reduce experiment that picks out an object with a matching property.
javascript
log = (msg) => {
document.body.innerHTML += `<pre>${msg}</pre>`;
};
foo = ["zomg", 666, { zork: "beep" }];
out = foo.reduce((acc, val) => {
if (val.zork && val.zork === "beep") {
return val;
}
});
log(out);
this demo preserves the compiled output and may depend on external libraries or services that are no longer available.