-1

Modify the car painting example car.color = favoriteColor ||"black"; so that the car is painted with your favorite color if you have one; otherwise it is painted with the the color of your garage: otherwise it is painted red.

I am missing some functions. This is what i have:

car.color = favoriteColor || "red";
function PaintCar (favoriteCar, garage, red)
{
  //The test succeeds if the favoriteColor boolean value is true.
  if favoriteColor
  {
    return "black"
  }
  // The test succeeds if either condition is true.
  if ((favoriteColor == "black") || (garage == "grey"))
  {
    return "";
  }
  else
  {
    return "car is paint is red";
  }
}

var reaction = GetReaction(false, "red");
document.write(reaction);
//Output: Car is finished.

1 Answer 1

1

I think the paintCar function makes more sense if you provide a reference to the car object and the colors of the garage and favorite.

function PaintCar (favoriteColor, garage, car)
{
  //The test succeeds if the favoriteColor boolean value is true.
  if (favoriteColor)
  {
    return car.color = favoriteColor
  }
  // The test succeeds if either condition is true.
  if (garage)
  {
    return car.color = garage
  }
  else
  {
    return car.color = "red"
  }
}
1
  • It makes more since. Thought I should add colors.
    – BreeA
    Commented Jul 12, 2015 at 6:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.