How to solve this problem?

  • 0
    Hello! There is a problem that should be solved through the for loop. But I don't understand how to solve it yet:

    Suppose you have an array with the names of the months. Let the variable month store the number of the current month, for example, 10. Use a loop to print all months, and print the current month in italics.
    JavaScript Eliot Harmon, Jul 18, 2019

  • 2 Answers
  • 0
    let months = [1,2,3,4,5,6,7,8,9,10,11,12]
    let month = 10
    let ul = document.createElement('ul')
    for(let i = 0; i<months.lenght; i++) {
    let li = document.createElement("li")
    li.innerHTML = i
    if(i+1 === 10)'cursive')

  • 0
    you iterate over all LETTERIAL months, when i = 10-1 (it is accepted to iterate over from scratch), you display the month in italics.

    const n =10;
    for (let i = 0; i < 12; i++) {
    //просто вывод
    if(i === (n-1)){
    //Вывод курсивом

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!