DEV Community

Discussion on: Understanding Generators in ES6 Javascript

Collapse
 
tuanphungcz profile image
Tuan Phung ⚡️ • Edited

yes, we can! You need to any function there ;)

function greeting() {
  console.log("Hi, Antonio!")
}

function* avengersGenerator() {
  yield "Hulk";
  yield greeting()
  yield "Spiderman";
}