<!DOCTYPE html> <html lang="en-US"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>Basic for loop example improved</title> <style> </style> </head> <body> <p></p> <script> const cats = ['Bill', 'Jeff', 'Pete', 'Biggles', 'Jasmin']; let info = 'My cats are called '; const para = document.querySelector('p'); for(let i = 0; i < cats.length; i++) { if(i === cats.length - 1) { info += 'and ' + cats[i] + '.'; } else { info += cats[i] + ', '; } } para.textContent = info; </script> </body> </html>