Skip to content

Instantly share code, notes, and snippets.

@artemis15
Created September 9, 2019 03:04
Show Gist options
  • Save artemis15/d04abd68bdb7b038995553b9b23ab372 to your computer and use it in GitHub Desktop.
Save artemis15/d04abd68bdb7b038995553b9b23ab372 to your computer and use it in GitHub Desktop.
Server js file with pokemon list
const app = require('express')();
const path = require('path');
//setting our app engine to handlebars
app.set('views', path.join(__dirname,'views'));
app.set('view engine', 'hbs');
app.get('/',(request,response)=>{
let _pokemonList = getRandomPokemonList();
response.render('index',{pokemon:_pokemonList});
});
let getRandomPokemonList = () => {
let _names = ['Pikachu' , 'charlizard' , ' Bulbasaur', 'Butterfree', 'Greninja'];
let limit = Math.floor(Math.random()*(_names.length -1 -0) +0); //generating random number between 0-4
return _names.slice(limit);
}
app.listen(3020,()=>console.log('node.js express server started at port 3020'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment