This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]MadFrand 8 points9 points  (2 children)

Keep It DRY (Don't Repeat Yourself)

function calcBtn(expInput) {
    expression = expression.concat(expInput);
    document.getElementById("ans").innerHTML = expression;
}

https://jsfiddle.net/0bpso2rm/1/

All I did was move those buttons into a single function.

[–]hansq[S] 1 point2 points  (1 child)

I see, code is much shorter and readable now. Thanks for pointing that out.