Refactor addValue function ttt.js