Wednesday, 12 April 2017

About character comparision in JavaScript

According to the route i type in in the address blank localhost:3000/ff00ff

here 'ff00ff', it should be like a hex code, if it is, reply Hello world,'ff00ff'! if it isn't, reply 404 not found.

but the problem is, it doesn't work. Hint:"Error: Uncaught error: reply interface called twice"

Here's the code i wrote

server.route({ method: 'GET', path: '/{name}', handler: function (request, reply) { var judge = new String(request.params.name); console.log(judge); for(var i=0; i<6; i++){ if (judge[i]==='0'||'1'||'2'||'3'||'4'||'5'||'6'||'7'||'8'||'9'||'a'||'b'||'c'||'d'||'e'||'f'||'A'||'B'||'C'||'D'||'E'||'F'){ reply('Hello, ' + judge + '!') } else{ reply('404 Page Not Found') }
} } });



via Zed.Yu

No comments:

Post a Comment