vendredi 6 septembre 2019

Convert ternary to if/else in mapped array function

I have a ternary within a map function, that currently only switches based on one option. I need to be able to pull the "home" option and set it to "/" if the user clicks that option

const buttons = ['Home', 'Docs', 'About-Us'];
const buttonSlugs = buttons.map(button => button === 'About-Us' ? 'aboutus' : button.toLowerCase());

How can I modify the ternary to an if/else, so that the home button can be set to "/"?

Aucun commentaire:

Enregistrer un commentaire