Jump to content

get vehicle price from array


Recommended Posts

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 by LeonMrBonnie
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...