Loops in ejs

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Instagram page</title>
</head>
<body>
    <h1>Welcome to the page of @<%=username%></h1>
    <button>Follow</button>
    <button>Message</button>
    <h3>Followed By</h3>
<ul>
    <% for(name of followers) { %>
    <li><%= name %></li>
    <% } %>
</ul>
</ul>
</body>
</html>





app.get("/ig/:username",(req,res)=>{
    const followers=["abhii","ash","bharath","vinay"];
    let {username}=req.params;
    res.render("insta.ejs",{username,followers});
})

Comments

Popular posts from this blog

DATABASE RELATIONSHIPS

ROUTING (GET /) home route

Query Strings