completed javascript with jasmine tests