From 138290b57a8028086448f540e4dfca4295f24f37 Mon Sep 17 00:00:00 2001 From: Octowl Date: Tue, 5 Nov 2024 08:47:28 +0300 Subject: [PATCH] update instructions and data --- objectIteration.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/objectIteration.js b/objectIteration.js index c42d97a..6db2e93 100644 --- a/objectIteration.js +++ b/objectIteration.js @@ -21,14 +21,14 @@ 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, @@ -36,37 +36,37 @@ const cars = [ }, ]; -// 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... }