JavaScript SolutionsJavaScript Solutions

🎆

Happy New Year

Week 1, 2026

All Solutions

JS - Simple Loops | program52 | JavaScript Solutions

//messy & unoptimised...but working function drawFireworks(size) { var half = Math.ceil(size / 2) var out = "" line = "" for (var offset = 1; offset <= size; offset++) { if (offset < half) { line = " ".repeat(offset - 1) + "\\" + " ".repeat(half - offset - 1) + "|" + " ".repeat(half - offset - 1) + "/" } else if (offset === half) { line = "-".repeat(size) } else { line = " ".repeat(size - offset) + "/" + " ".repeat(half - (size - offset) - 2) + "|" + " ".repeat(half - (size - offset) - 2) + "\\" } out = out + line + "\n" } console.log(out) } drawFireworks(99)