DWQA QuestionsCategory: ProgramMeet a front-end interview question: print 500 asterisks without cycling
Spoony laugh at me asked 1 month ago

Print 500 asterisks without cycling
Don’t make such a joke by hand

2 Answers
Best Answer
papersnake answered 1 month ago
console.log(new Array(500).fill('*'))
If you don't want array format, you can add a string
console.log(new Array(500).fill('*').toString())


The above method is not convenient. I think the interviewers want to test your recursion
function printstart(i){
  console.log('*')
  if(i<500){
    i++
    printstart(i)
    
  }
}

printstart(0)
Feng Heng Zhi replied 1 month ago

This is the 499 one.

Spoony laugh at me answered 1 month ago
console.log(new Array(500).fill('*').toString().replace(/\,/g," "))

console.log(new Array(500).join('*'))