const recipes = [
{
title: 'Crepes',
duration: 60,
ingredients: ['butter', 'flour', 'eggs', 'milk', 'salt'],
servings: 3
},
{
title: 'Scrambled Eggs',
duration: 20,
ingredients: ['eggs', 'milk', 'salt'],
servings: 2
},
{
title: 'Vegan Salmon',
duration: 60 * 24 * 3, // 3 days
ingredients: ['carrots', 'olive oil', 'nori sheets', 'liquid smoke', 'soy sauce'],
servings: 10
},
{
title: 'Carot Cake',
duration: 120,
ingredients: ['carrots', 'flour', 'eggs', 'salt', 'milk', 'sugar'],
servings: 10
}
]
I want to create an array like this:
['Crepes (60min)', ...]
Thats my code so far:
const titlesWithDuration = recipes.map((titles) => {
return `${titles.title} (${titles.duration}min)`;
});
console.log(titlesWithDuration)
Problem is, if i use things like operators, for example:
titles.duration <= 60
i will get this:
["Crepes (truemin)","Scrambled Eggs (truemin)","Vegan Salmon (falsemin)","Carot Cake (falsemin)"]
How can i use operators which give me a string output?