Update test.js

changed coding to be simpler