add Solution 1-7 in JavaScript