Added javascript code according to task