Freamee 0 Posted October 30 Hello. i Would like to create a function like GetVehiclePrice(carname), and it gets the price from the array. Appreciate the help. Share this post Link to post Share on other sites
LeonMrBonnie 5 Posted October 30 (edited) const CarPrices = { "zentorno": 5000, "turismor": 10000 }; function getVehiclePrice(carname) { return CarPrices[carname] || null; } Just add the vehicles to the object like the example. The functions returns either the price of the vehicle, or null if the vehicle is not found. Edited October 30 by LeonMrBonnie Share this post Link to post Share on other sites