I'm trying to display within 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, for example: <%= helloWord %>
, but now I'm trying to execute a for
inside this tag to show the data in an array, but it is not working. Does anyone know how to make this work? Below is the code for the page:
<!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>