Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
October 4, 2022 04:52 am GMT

New Usefull JavaScript Tips For Everyone

*Old Ways *

 const getPrice = (item) => {  if(item==200){return 200}    else if (item==500){return 500}   else if (item===400) {return 400}   else {return 100}}console.log(getPrice(foodName));

New Ways

const prices = { food1 : 100, food2 : 200, food3 : 400, food4 : 500}const getPrice = (item) => { return prices[item]}console.log(getPrice(foodName))

Hope you like my new tricks :D

follow my github account


Original Link: https://dev.to/shaon07/new-usefull-javascript-tips-for-everyone-1389

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To