I have the following code which I wrote, but there is so much of code duplication. I would like to minimize it but I am unable to come up with the ideas. Could anyone help me out with this?
myFunc(r: Object): Object {
if (condition) {
return {
x: this._width - r.w * this._cellSize - r.x * this._cellSize - CELL_PADDING * 2,
y: this._offsetToScreen(r.y),
w: r.w * this._cellSize - CELL_PADDING * 2,
h: r.h * this._cellSize - CELL_PADDING * 2,
z: r.z
}
} else {
return {
x: this._offsetToScreen(r.x),
y: this._offsetToScreen(r.y),
w: r.w * this._cellSize - CELL_PADDING * 2,
h: r.h * this._cellSize - CELL_PADDING * 2,
z: r.z
}
}
}
x
, yet you are unable to come up with any ideas? What have you tried? – user949300 Nov 21 '16 at 17:34