Reputation: 84
I have the following block of code:
<div className="max">
{Math.max.apply(
Math,
items.feeds.map(function(o) {
const temp = 34;
if(o.field1 <= temp) {
return <b>{o.field1}</b>; //return NaN
}
else {
return o.field1;
}
})
)}
</div>
However, the if statement returns NaN. If I just return o.field1, it works. Like this:
items.feeds.map (function (o) {return o.field1}
Is there an issue in my if statement? I want if the value of o.field1 satisfies the condition when printing to screen it is bold.
Upvotes: 0
Views: 49
Reputation: 11000
Math.max
returns a number:
Return value: The largest of the given numbers. If at least one of the arguments cannot be converted to a number, NaN is returned.
What you return is <b>{o.field1}</b>
- it cannot be converted to a number. Wrap returned number with <b>
tags later.
Upvotes: 1