CHALLENGE
class DataProcessor {
constructor(value) {
this.value = value;
}
transform(fn) {
return new DataProcessor(fn(this.value));
}
getValue() {
return this.value;
}
}
const multiply = x => x * 2;
const add = x => x + 10;
const square = x => x * x;
const result = new DataProcessor(5)
.transform(multiply)
.transform(add)
.transform(square)
.getValue();
console.log(result);
❤1
❤4👍2🔥1