add Solution 1-3 in JavaScript