tracks/javascript/exercises/protein-translation/example.js in trackler-2.2.1.46 vs tracks/javascript/exercises/protein-translation/example.js in trackler-2.2.1.47
- old
+ new
@@ -4,20 +4,19 @@
function translate(rnaStrand) {
var proteins = [];
if (rnaStrand) {
- for (var i = 0; i < rnaStrand.length; i+=3) {
+ for (var i = 0; i < rnaStrand.length; i += 3) {
var protein = getProtein(rnaStrand.substring(i, i + 3));
if (protein) {
-
- if (protein === "STOP") {
+ if (protein === 'STOP') {
break;
}
- if (protein === "INVALID") {
+ if (protein === 'INVALID') {
throw new Error('Invalid codon');
}
proteins.push(protein);
}
@@ -27,42 +26,42 @@
return proteins;
}
function getProtein(codon) {
switch (codon) {
- case "AUG":
- return "Methionine";
+ case 'AUG':
+ return 'Methionine';
- case "UUU":
- case "UUC":
- return "Phenylalanine";
+ case 'UUU':
+ case 'UUC':
+ return 'Phenylalanine';
- case "UUA":
- case "UUG":
- return "Leucine";
+ case 'UUA':
+ case 'UUG':
+ return 'Leucine';
- case "UCU":
- case "UCC":
- case "UCA":
- case "UCG":
- return "Serine";
+ case 'UCU':
+ case 'UCC':
+ case 'UCA':
+ case 'UCG':
+ return 'Serine';
- case "UAU":
- case "UAC":
- return "Tyrosine";
+ case 'UAU':
+ case 'UAC':
+ return 'Tyrosine';
- case "UGU":
- case "UGC":
- return "Cysteine";
+ case 'UGU':
+ case 'UGC':
+ return 'Cysteine';
- case "UGG":
- return "Tryptophan";
+ case 'UGG':
+ return 'Tryptophan';
- case "UAA":
- case "UAG":
- case "UGA":
- return "STOP";
+ case 'UAA':
+ case 'UAG':
+ case 'UGA':
+ return 'STOP';
- default:
- return "INVALID";
+ default:
+ return 'INVALID';
}
}