advanced flow converted if statement

PHOTO EMBED

Wed Dec 21 2022 03:37:57 GMT+0000 (Coordinated Universal Time)

Saved by @davidmchale #dynamic #advanced-flow #object

const getMessages = (status) => {
  // if(status === 'received'){
  //      return 'We are working on your order'
  // }else if(status === 'prepared'){
  //       return `Food is ready for collection`
  // }else if(status === 'onroute'){
  //       return `Your food is on its way`
  // }else if(status === 'arrived'){
  //   return `Your food has been delivered and signed for`
  // }else{
  //   return `unknown status`
  // }


  const messages = {
    received: 'We are working on your order',
    prepared: `Food is ready for collection`,
    onroute: `Your food is on its way`,
    arrived: `Your food has been delivered and signed for`
  }


  return messages[status] ?? 'unknown status'
}


const user = {
  name: 'David',
  status: 'arrived'
}


console.log(getMessages(user.status))
content_copyCOPY