Wednesday 28 November 2018

Checking for page type

I have a place.ejs that can display three different types: country, city, attraction. I want to list the cities if the type is country, attractions if the type is city, and nothing if type is attraction. How do I compare which placeType is being used at the moment?
<% if ( placeType == 'countries') { %><% standinCity.forEach((city) => { %>
  • <%= city.name %>
  • <% }); %><% } %><% else if ( placetype == 'cities' ) { %><% standinAttraction.forEach((attraction) => { %>
  • <%= attraction.name %>
  • <% }); %><% } %><% else { %><% } %>
The only issue is in the if-statement comparisons. Everything within the statements work.

Submitted November 29, 2018 at 03:31AM by Charizma02

No comments:

Post a Comment