Skip to content

Commit

Permalink
update instructions and data
Browse files Browse the repository at this point in the history
  • Loading branch information
Octowl committed Nov 5, 2024
1 parent 9a8372d commit 138290b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions objectIteration.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,52 +21,52 @@ const cars = [
color: "Red",
},
{
id: 404,
id: 405,
make: "Chevrolet",
model: "Tahoe",
year: 2022,
color: "Black",
},
{
id: 405,
id: 406,
make: "Nissan",
model: "Altima",
year: 2020,
color: "White",
},
];

// 1) Using `getCarMake` function that accepts a `car` object, return the make (brand) of the car
// 1) Write a `getCarMake` function that accepts a `car` object, return the make (brand) of the car
function getCarMake(car) {
// write your code here...
}
// console.log(getCarMake(cars[0])); // Outputs: Toyota

// 2) Using `isCarColorMatching` function that accepts `car` object and `color` string arguments, return true if the car's color matches the provided color, otherwise returns false
// 2) Write a `isCarColorMatching` function that accepts `car` object and `color` string arguments, return true if the car's color matches the provided color, otherwise returns false
function isCarColorMatching(car, color) {
// write your code here...
}
// console.log(isCarColorMatching(cars[1], "Blue")); // Outputs: false

// 3) Using `addCar` function that accepts an array of car objects `cars` and the properties of a car, create a new car object and add it to the array of cars, and return the updated array
// 3) Write a `addCar` function that accepts an array of car objects `cars` and the properties of a car, create a new car object and add it to the array of cars, and return the updated array
function addCar(cars, id, make, model, year, color) {
// write your code here...
}
// console.log(addCar(cars, 406, "Kia", "Sorento", 2021, "Green"));

// 4) Using `countCarsMadeInYear` function that accepts an array cars objects `cars` and a manufacturing year `year` in numbers, return the number of cars made in the specified year
// 4) Write a `countCarsMadeInYear` function that accepts an array cars objects `cars` and a manufacturing year `year` in numbers, return the number of cars made in the specified year
function countCarsMadeInYear(cars, year) {
// write your code here...
}
// console.log(countCarsMadeInYear(cars, 2020)); // Outputs: 2

// 5) Using `removeCarById` function that accepts an array of cars objects `cars` and an `id` of number, remove the car with matching id from the array, and return the updated array.
// 5) Write a `removeCarById` function that accepts an array of cars objects `cars` and an `id` of number, remove the car with matching id from the array, and return the updated array.
function removeCarById(cars, id) {
// write your code here...
}
// console.log(removeCarById(cars, 404));

// 6) Using `updateCarColor` function that accepts the following arguments: an array of car objects `cars`, an `id` (number) and a `newColor` (string), updates the color of the car with the given id to the new color. and return the updated car object. If no car is found with the given id, return "No Car Found".
// 6) Write a `updateCarColor` function that accepts the following arguments: an array of car objects `cars`, an `id` (number) and a `newColor` (string), updates the color of the car with the given id to the new color. and return the updated car object. If no car is found with the given id, return "No Car Found".
function updateCarColor(cars, id, newColor) {
// write your code here...
}
Expand Down

0 comments on commit 138290b

Please sign in to comment.