#Javascript-vehicle-purchase.js

24 messages · Page 1 of 1 (latest)

golden bridge
#

Hi, I'm working on instruction 2 for this exercises and seem to be stuck figuring out to make it choose the right option.

#
export function chooseVehicle(option1, option2) {
  if (option2[0] > option1[0]){
    return option2 + "is clearly the better choice.";
  } else if (option1[0] > option2[0]) {
    return option1  + "is clearly the better choice.";
  }
}
candid gale
#

What's the test failure say for this code?

golden bridge
#
Error: expect(received).toBe(expected) // Object.is equality

Expected: "Bugatti Veyron is clearly the better choice."
Received: "Ford Pintois clearly the better choice."
#

Below is the code run

#
expect(chooseVehicle('Bugatti Veyron', 'Ford Pinto')).toBe(
      'Bugatti Veyron' + rest,
    );
expect(chooseVehicle('Chery EQ', 'Kia Niro Elektro')).toBe(
      'Chery EQ' + rest,
    );
candid gale
#
  1. Do you understand what the test is doing?
  2. Do you understand what the test is expecting and why?
  3. Do you understand what your code returns and how it differs?
  4. Do you understand why your code is returning what it returns?
golden bridge
#
  1. the test is asking me to sort which option is first in dictionary order and asking me to return it with a sentence at the end
#

i don’t understand why my code is returning something different

candid gale
#

What should your code return vs what does it return?

#

Can you be specific about what your code is doing wrong?

#

@golden bridge ?

golden bridge
#

Sorry

#

My code is returning the other value

#

I think I got it

#

Nevermind

candid gale
#

All solved?

golden bridge
#

It did not pass one of the test

#

Sorry give me a moment

#

Okay

candid gale
#

Sure

golden bridge
#

It passed!

#

Thank you for your help

candid gale
#

Congrats!