1
I’m trying to show inside an EJS/html file the values of an array that are sent from the server, but I’m not getting it.
I know that to show the value of a variable inside an EJS file all I need to do is put the variable name inside the tags <=% %>
, as an example: <%= helloWord %>
, but now I’m trying to run a loop for
inside this tag to show the data of an array, but it’s not working. Does anyone know how to make it work? Follow below page code:
<!DOCTYPE html>
<html>
<head>
<title>Página Inicial</title>
<link rel='stylesheet' href='/stylesheets/style.css' />
</head>
<body>
<h3><%= artwork %></h3>
<center>
<img src="images/IMG01.jpg" alt="Imagem da Obra de Arte 1" title="Obra de Arte 1"></br>
</center>
<div class="container">
<p id="message">
<%=
for(let i = 0; i < 10; i++){
log[i];
}
%>
</p>
<form method="POST">
<input type="text" name="inputQuestion" placeholder="Pergunte-me" required />
<button>Enviar</button>
</form>
</div>
</body>
</html>
I get it. Just one more thing, if I wanted the value of
i
within thefor
is up to the size of the array, as I should then put?– CloudAC
would be like in javascript itself, "for(Let i = 0; i < log.length; i++)"
– Marcelo Junior