Reputation: 416
I have this scenario, but it's not working...
Under h1
I want to show all elements from my array and in input value I want to show the last element from my array:
<h1>Solutions></h1>
<% var element = title.forEach(function(item) { %>
<p><%= item.name%></p>
<% }) %>
<form action="/" method="post">
<input type="text" name="name" />
<input type="text" name="s" placeholder="solution subtitle"
value=
<%= element.length-1 %>
/>
<button type="submit" name="submit">Submite</button>
</form>
How can I get the last element from array using eJS?
Upvotes: 0
Views: 427