JSFiddle - React, Tailwind, and code Playground
by Allie Yu
JavaScript
class Animal{
constructor(name,type){
this.animal = true;
this.name = name
this.type= type
}
sayHello(){
//console.log('heyyyaaa')
var num = Math.random() * 10;
return new Promise( (resolve,reject) => {
/*(num >= 5)? resolve('Yesss ' + num) : reject('Failed ' + num )
*/
setTimeout( () => resolve('Babbbyy i need your loving') , 4000 )
})
}
async asyncHello(){
const greeting = await this.sayHello()
console.log(greeting)
console.log('Im only gonna run after sayhello is finished , after promise is reolved')
}
}