或与EJS调理?

问题描述 投票:1回答:1

这两个语句的工作:

  <% if(currentUser.collegeLevel === "High School") { %>    
  <h1>  They have a High School Degree </h1>
  <% } %>


  <% if(currentUser.collegeLevel === "Associates Degree") { %>    
  <h1> They have an Associates Degree </h1>
  <% } %>

此语句不工作

<% if(currentUser.collegeLevel === "Associates Degree" || "High School") { %>    


 <h1> They have either a High school or Associates Degree</h1>

  <%  } %>

为什么OR功能无法正常工作?

html if-statement ejs
1个回答
3
投票

这是行不通的,因为或不反对别的比较..

它应该是这样的:

if(currentUser.collegeLevel === "Associates Degree" || currentUser.collegeLevel === "High School")

© www.soinside.com 2019 - 2024. All rights reserved.