answers = [a1, a2] mapper = { 'Yes': 'Yes' 'No': 'No' 'Yes - UK Modern Slavery Act': 'Yes' 'Yes - California Transparency in Supply Chains Act': 'Yes' 'Yes - Australian Modern Slavery Act': 'Yes' 'Yes - Norwegian Transparency Act': 'Yes' 'Yes - Canadian Act': 'Yes' 'No - neither': 'No' } mapAnswer = (answer) -> if answer of mapper return mapper[answer] if Array.isArray answer for category in answer if category of mapper return mapper[category] "Unknown" mappedAnswers = answers.map (answer) -> mapAnswer(answer) mappedAnswers[0]