I currently have this answer that works fine
function pairElement(str) {
let dnaStr = [];
dnaStr = str.split('').map( function(x) {
switch(x) {
case 'A': return ['A','T'];
break;
case 'T': return ['T','A'];
break;
case 'C': return ['C','G'];
break;
case 'G': return ['G','C'];
break;
};
});
return dnaStr;
}
pairElement("ATCGA");
Why does this not work if i change the function within the map argument to an arrow function format like this:
function pairElement(str) {
let dnaStr = [];
dnaStr = str.split('').map( x => (
switch(x) {
case 'A': return ['A','T'];
break;
case 'T': return ['T','A'];
break;
case 'C': return ['C','G'];
break;
case 'G': return ['G','C'];
break;
};
));
return dnaStr;
}
pairElement("ATCGA");
I get a syntax error. Why does the arrow function format not work. Have i written that incorrectly?
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:66.0) Gecko/20100101 Firefox/66.0
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/dna-pairing