JavaScript innerHTML not working in this particular script

I want to take every element of from the API and show it in different classes. I am getting the result in my Console but not on the page. Please Help me out. Thanks you in Advance:) .

I have used JavaScript with Jquery.

<script>

$.getJSON('https://api.noopschallenge.com/wordbot?count=5',  function(data){
        console.log(data);     




    for(let i=0; i<5; i++)
        {
            var box = document.createElement("div");
            box.setAttribute("class", i);
            document.body.appendChild(box);
            let dat = `${data.words[i]}`;
            let a = i.toString();
            document.getElementsByClassName(a).innerHTML = dat;
            console.log(dat);

        }
     });

</script>
Answer:1

getElementsByClassName() returns an array-like object of all child elements which have all of the given class names, you have to use proper index:

document.getElementsByClassName(a)[0].innerHTML = dat;
Answer:2

getElementsByClassName returns an HTML Collection

for (let element of document.getElementsByClassName(a)) {
    element.innterHTML = dat
}

This should work

Answer:3

I am trying to manipulate some float values inside of a string by a certain amount. To do so I have the following: var string = '<path d="M219.6,-71.4C249,19.1,212.7,130.9,135.7,186.8C58.8,242....

I am trying to manipulate some float values inside of a string by a certain amount. To do so I have the following: var string = '<path d="M219.6,-71.4C249,19.1,212.7,130.9,135.7,186.8C58.8,242....

I looking to post leads from my MSSQL database to a third party site. I've created a page that queries the database and inserts values into form fields so that I can manually press a submit button. ...

I looking to post leads from my MSSQL database to a third party site. I've created a page that queries the database and inserts values into form fields so that I can manually press a submit button. ...

I've got this Electron app (using NodeJS, Bootstrap, AngularJS) with some text input fields that can be edited. I have a button that triggers a window.alert() After it has been triggered, the text ...

I've got this Electron app (using NodeJS, Bootstrap, AngularJS) with some text input fields that can be edited. I have a button that triggers a window.alert() After it has been triggered, the text ...

  1. canvas
  2. canada
  3. cancelled
  4. canceled vs cancelled
  5. cancun
  6. canada goose
  7. cane corso
  8. canes
  9. canadian prime minister
  10. cancun flights
  11. canker sore
  12. candy
  13. cancer
  14. canon
  15. canvas prints
  16. cancer sign
  17. candace owens
  18. canada news
  19. candytopia
  20. canlis

From the code underneath, I want to remove the previous instances of codemirror, that is both "hello" and "hii" before I can add another instance. The jQuery is not working. Also, if I console.log($('...

From the code underneath, I want to remove the previous instances of codemirror, that is both "hello" and "hii" before I can add another instance. The jQuery is not working. Also, if I console.log($('...