Javascript Error occure : has correct values

i am getting an error: has correct values.
expected ['34 10', '90 50', '59 25']; to equal [3,4, 1.8,2.36]

anybody can help me to resolve an issue.

index.js

var roundtrip = [
  { distance: 34, time: 10 },
  { distance: 90, time: 50 },
  { distance: 59, time: 25 }
];

var speeds=roundtrip.map(getFullName);

function getFullName(item) {
  var app = [item.distance,item.time].join(" ");
  return app;
}

Hi there, is that a fCC challenge? What’s the task?

From the solution you posted, I guess you’re supposed to return an array of speed values. To calculate the speed:

speed = distance / time

Does that help?

HI @raju.kapadne09!

Welcome to the forum!

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Requirement :

Using map, create a new array that contains the distance/time value from each trip. In other words , the new array should contain the (distance/time) value. Assign the result to the variable ‘speeds’.

var trips = [
  { distance: 34, time: 10 },
  { distance: 90, time: 50 },
  { distance: 59, time: 25 }
];

var speeds;

what have you tried?


I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

.map is an array method that takes an array, performs a routine on all the items (like, for example, divide the distance property of the item by the time property of the item), and returns a new array.

you were pretty near here, only that instead of joining the numbers to make a string, you need to make a mathematical operation between the two numbers

Thank you so much . I applied your suggested speed formula and now my error been resolved.