这个例子没有体现出generator函数的特性啊,本来就是一个普通函数就能完成的功能。
function getPrice(){
return Math.random()*100;
}
var limitPrice=15;
var price =100;
while(price>limitPrice){
price=getPrice();
console.log(`price is ${price}`);
}
console.log(`buy price is ${price}`);
function getPrice(){
return Math.random()*100;
}
var limitPrice=15;
var price =100;
while(price>limitPrice){
price=getPrice();
console.log(`price is ${price}`);
}
console.log(`buy price is ${price}`);
2017-08-20