Intermediate Algorithm Scripting: Homework (Fall 2022)

Hey JavaScripters !

Great job today! :purple_heart: Loved the collaborative and curious minds of today’s lesson! I hope you will continue bring all of this energies during your awesome learning journey!

:loudspeaker: Quick reminder about homework for the next session!
Tomorrow we’ll start with our last project Building A Cash Register , so your homework is to finish the intermediate algorithm section and, if you have time and energies, check the last project before solving it together!

Remember folks, you’re not alone.
Don’t hesitate to seek help in the #js-help channel or on the forum!

Be sure to collaborate, stay hydrated and get plenty of rest!!!

We’re all in this together!
Happy Coding!

2 Likes

Hi there!
I would really appreciate if you could cover this exercise in the Q and A tomorrow please - I feel I am almost there, but it is not quite coming together, ha ha.

I just need to work out how to automatically substitute the individual letters for their corresponding two letter arrays. Thanks to you or anyone else who can help :slight_smile:

And thanks for a fantastic boot camp :smiling_face:

function pairElement(str) {

  const pairs = {
    "G": ["G", "C"],
    "C": ["C", "G"],
    "A": ["A", "T"],
    "T": ["T", "A"]
}

  let myRegex = (/G+|C+|A+|T+/g);
let newStr = str.match(myRegex);
console.log(newStr);
let finalStr = newStr;
finalStr.pop();
finalStr.push(pairs["A"]);
finalStr.shift();
finalStr.unshift(pairs["A"]);

// should i be converting the array to a string first?
// access array items using index [0] etc.
let continuedStr = finalStr.join(pairs["T", "A"]);
console.log(continuedStr)
//how do i replace eg. "G" with ["G", "C"] automatically

console.log(finalStr)

  
  //return reallyNewStr
  //[newStr.split(newStr).join(pairs)];
}

console.log(pairElement("ATCGA"));

contents of console:

[ 'A', 'T', 'C', 'G', 'A' ]
A,TA,TTA,TCA,TGA,TA,T
[ [ 'A', 'T' ], 'T', 'C', 'G', [ 'A', 'T' ] ]
undefined
1 Like

In fact - ha ha ha - while reviewing all the remaining Intermediate Algorithm Scripting Exercises, I think I will be struggling a lot going through this alone - can we go through some more of the exercises in the Q and A tomorrow please? And - will this (tomorrow) be the last ever Q and A? Is there any chance in having a final round up session, e.g. next week?
Not sure if I am being cheeky or not here, as I do appreciate you have already given us so much of your time and expertise. Anyway, I’m asking. :grinning:
Thanks for everything regardless.

1 Like

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.