[text] Objects

Viewer

  1. const express=require("express");
  2. const app=express();
  3. app.set("view engine","ejs");
  4. const arr=[{id:1,name:"pavan",age:21},{id:2,name:"nithin",age:21},{id:3,name:"nikil",age:24}];
  5. app.get("/profile",(req,res)=>{
  6.   res.render("profile",{arr});
  7. });
  8. app.listen(3005,()=>
  9. {
  10.     console.log("Server Listening...");
  11. });
  12.  
  13.  
  14.  
  15. profile.ejs
  16. <html>
  17.     <body>
  18.         <% arr.forEach((ele)=>{%>
  19.         <h1>Person Id: <%=ele.id %> </h1>
  20.         <h2>Person Name:<%=ele.name%></h2>
  21.         <h3>Person Age:<%=ele.age%></h3>
  22.         <%});%>
  23.     </body>
  24. </html>

Editor

You can edit this paste and save as new:


File Description
  • Objects
  • Paste Code
  • 25 Apr-2024
  • 565 Bytes
You can Share it: