<sectionid="description"> Ahora que está obteniendo datos de una API JSON, puede mostrarlos en el HTML. Puede usar un método <code>forEach</code> para recorrer los datos, ya que los objetos de la foto del gato se mantienen en una matriz. A medida que llegas a cada elemento, puedes modificar los elementos HTML. Primero, declare una variable html con <code>var html = "";</code> . Luego, recorra el JSON, agregando HTML a la variable que envuelve los nombres de las claves en etiquetas <code>strong</code> , seguido del valor. Cuando el bucle termina, lo renderizas. Aquí está el código que hace esto: <blockquote> json.forEach (función (val) { <br> var keys = Object.keys (val); <br> html + = "<div class = 'cat'>"; <br> keys.forEach (function (key) { <br> html + = "<strong>" + clave + "</strong>:" + val [clave] + "<br>"; <br> }); <br> html + = "</div><br>"; <br> }); </blockquote></section>
<sectionid="instructions"> Agregue un método <code>forEach</code> para recorrer los datos JSON y crear los elementos HTML para mostrarlos. Aquí hay un ejemplo de JSON <blockquote> El <br> { <br>"id": 0, <br>"imageLink": "https://s3.amazonaws.com/freecodecamp/funny-cat.jpg", <br>"altText": "Un gato blanco con un casco verde con forma de melón en la cabeza". <br>"codeNames": ["Juggernaut", "Mrs. Wallace", "Buttercup"<br> ] <br> } <br> ] </blockquote></section>