Created
September 9, 2019 03:04
-
-
Save artemis15/d04abd68bdb7b038995553b9b23ab372 to your computer and use it in GitHub Desktop.
Server js file with pokemon list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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