mhtien / js-calculator

JavaScript Calculator
https://mhtien.github.io/js-calculator/
0 stars 0 forks source link

Name reused expressions #5

Open oliverjam opened 4 years ago

oliverjam commented 4 years ago

If you're going to use a complex-ish expression multiple times it's a good idea to give it a descriptive name.

https://github.com/mhtien/js-calculator/blob/d220d0209c55d1f10150d0f5dc68ab42bffe1d78/script.js#L218-L235

operatorsArray[i] isn't too hard to parse, but you could save yourself some typing/reading later on with const operator = operatorsArray[i] at the top.

mhtien commented 4 years ago

Thanks again for the tips! It does read a lot clearer now :+1:

View changes here