代码之家  ›  专栏  ›  技术社区  ›  AndrewLeonardi

还是EJS的情况?

  •  1
  • AndrewLeonardi  · 技术社区  · 7 年前

    这两种说法都有效:

      <% 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>
    
      <%  } %>
    

    为什么或函数不工作?

    1 回复  |  直到 7 年前
        1
  •  3
  •   Adrian    7 年前

    它不起作用,因为或没有与其他任何东西进行比较。

    它应该是这样的:

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