re: Why you shouldn't reassign values in JavaScript VIEW POST


Even easier to read?

function getHairType (today) {
  return {
    Monday: 'bangs',
    Tuesday: 'braids',
    Wednesday: 'short hair',
    Thursday: 'long hair',
    Friday: 'bright pink hair'
  } [today];

@miguelqueiroz - I was thinking the same. Admittedly the function wrapper above is pointless


That's my point. But its funny to know your hair is sort of undefined for Saturday or sundays ehe..


Ooh! You're completely right there. I should have came up with a better example 😅.

code of conduct - report abuse