# Intermediate Algorithm Scripting: Homework (Fall 2022)

**URL:** https://group.classcentral.com/t/intermediate-algorithm-scripting-homework-fall-2022/35956
**Category:** JavaScript Bootcamp
**Created:** [October 11, 2022, 10:41am UTC](https://group.classcentral.com/t/intermediate-algorithm-scripting-homework-fall-2022/35956 "2022-10-11T10:41:47Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![hola\_soy\_milk](https://sea2.discourse-cdn.com/flex016/user_avatar/group.classcentral.com/hola_soy_milk/32/600_2.png) [@hola\_soy\_milk](https://group.classcentral.com/u/hola_soy_milk)
#### Post date: [October 11, 2022, 10:41am UTC](https://group.classcentral.com/t/intermediate-algorithm-scripting-homework-fall-2022/35956/1 "2022-10-11T10:41:47Z")

</div>

Hey **JavaScripters**!

Great job today! 💜 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!

📢 **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!

---

<div class="post-metadata">

### Author: ![Jane2963637](https://sea2.discourse-cdn.com/flex016/user_avatar/group.classcentral.com/jane2963637/32/6117_2.png) [@Jane2963637](https://group.classcentral.com/u/Jane2963637)
#### Post date: [October 11, 2022, 5:29pm UTC](https://group.classcentral.com/t/intermediate-algorithm-scripting-homework-fall-2022/35956/2 "2022-10-11T17:29:18Z")

</div>

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 🙂

And thanks for a fantastic boot camp ☺

```auto
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:

```auto
['A', 'T', 'C', 'G', 'A']
A,TA,TTA,TCA,TGA,TA,T
[[ 'A', 'T'], 'T', 'C', 'G', ['A', 'T'] ]
undefined

```

---

<div class="post-metadata">

### Author: ![Jane2963637](https://sea2.discourse-cdn.com/flex016/user_avatar/group.classcentral.com/jane2963637/32/6117_2.png) [@Jane2963637](https://group.classcentral.com/u/Jane2963637)
#### Post date: [October 11, 2022, 5:37pm UTC](https://group.classcentral.com/t/intermediate-algorithm-scripting-homework-fall-2022/35956/3 "2022-10-11T17:37:46Z")

</div>

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. 😀  
Thanks for everything regardless.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex016/uploads/ccstudygroup/original/1X/36206832181ed26910a18e33d8bfef087cf661b1.svg) [@system](https://group.classcentral.com/u/system)
#### Post date: [November 25, 2022, 5:38pm UTC](https://group.classcentral.com/t/intermediate-algorithm-scripting-homework-fall-2022/35956/4 "2022-11-25T17:38:21Z")

</div>

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