Created
June 30, 2020 19:45
-
-
Save jeremymouzin/6f83323cc6beeabd12fb8304df4cba23 to your computer and use it in GitHub Desktop.
Challenge 6 du Challenge JavaScript 10 jours de Scrimba
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Solution simple via concaténation | |
function encloseInBrackets(chaine) { | |
return '(' + chaine + ')'; | |
} | |
// Solution simple via template strings | |
function encloseInBrackets(chaine) { | |
return `(${chaine})`; | |
} | |
// Solution inutilement complexe (over-engineered) | |
function encloseInBrackets(chaine) { | |
chaine = [...chaine]; | |
chaine.unshift('('); | |
chaine.push(')') | |
return chaine.join(''); | |
} | |
// Solution inutilement complexe 2 (over-engineered) | |
function encloseInBrackets(chaine) { | |
const brackets = ['(',')']; | |
brackets.splice(1, 0, chaine); | |
return brackets.join(''); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment