function secondCheapest(bookObj){
const price = bookObj.map(bookObj => {
return bookObj.price
})
const name = bookObj.map(bookObj => {
return bookObj.title
})
let lowest = Math.min(...price)
let second = price.filter(value => value != lowest)
let n = Math.min(...second)
return n
}
console.log(secondCheapest([
{title:'Fox In Socks', price:32.20},
{title:'The Cat In The Hat', price:16.20},
{title:'Green Eggs and Ham', price:28.50},
{title:'Thinking Fast and Slow', price:58.80},
{title:'War and Peace', price: 5.20}
]));
I
I’m stuck here please help… I’m trying to return the second lowest price of the book here, but my code is printing the second price only. How can I make the code to print both the title and the price such as… title:‘The Cat In The Hat’, price:16.20