Feeling discouraged - ShiftCipher challenge (intermediate JavaScript Syntax III)

Hello,

I’ve been learning JavaScript since January this year and according to where I am at in the course, I am now at the ‘intermediate’ level.

Depending on the complexity level, I can complete the guided exercises included in each lesson with relative ease, but when the time comes to tackle a challenge on my own, from scratch, I am completely lost. All of a sudden, everything I just learned and previous becomes fuzzy, confusing and I don’t know where to start. I struggle to even understand the guidelines and I find myself reading them over and over, to try and make some sense of what is being asked.

I look for solutions on this site, on Discord, GitHub, I Google, use MDN, W3C, look for specific tutorials on YouTube, use books, etc, etc, etc…

When I do find solutions, most of them are far too complex for me which frustrates and discourages me even more because all I can think of is how much more ahead of me those other students are, how they get it and I don’t. I read the interactions when someone asks a question and when they’re given solutions, they get it and I still don’t. It really makes me feel as though I may not be cut out for this.

I have until the end of October to complete the entire course with projects on the side and I am very anxious. I struggle so much to get the logic. I often think to myself, as I did with the attached exercise: “Do they really expect me to understand this and come up with a solution?”

I guess the reason I decided to post this is because I am looking for reassurance, encouragement. Is this normal? Is this ok? Can I really feel this much out of my depth today and yet be a proficient developer fast forward X months/ years?

It would be nice to read realistic and positive feedback from anyone who knows exactly how I feel, who’s been there and has overcome.

This is the challenge that prompted my post:
https://www.codecademy.com/paths/full-stack-engineer-career-path/tracks/fscp-22-javascript-syntax-part-iii/modules/wdcp-22-practice-javascript-syntax-classes/articles/fecp-javascript-practice-classes

If it isn’t already obvious, I didn’t come up with the solution! I did study it though, and I understand it for the most part. I just would not have been able to come up with it by myself, most definitely not!

  1. AFTER seeing the solution, it took me ages to get my head around the numbers 90, 65, 122, 97. “How on earth did people come up with that?!”, I asked myself. It took a lot of time and digging and I eventually got it through Wikipedia.

  2. I don’t understand the following lines:

let charNum = tempString.charCodeAt(i);

encryptString += String.fromCharCode(charNum);

If I do come across as being a lot slower than I should be, then so be it, that would just confirm my current frame of mind. But if anyone has some good words of encouragement, that would spur me on and I would be ever so grateful!

Thank you!

class ShiftCipher {
  constructor(shift) {
    this.shift = shift;
  }

  encrypt(plainString) {
    let encryptString = '';
    const tempString = plainString.toUpperCase();

    for (let i = 0; i < tempString.length; i++) {
      let charNum = tempString.charCodeAt(i);

      if (charNum <= 90 && numChar >= 65) {
        charNum += this.shift;
        if (charNum > 90) {
          charNum += 26;
        }
      }
      encryptString += String.fromCharCode(charNum);
    }
    return encryptString;
  }

  decrypt(plainString) {
    let decryptString = '';
    const tempString = plainString.toUpperCase();

    for (let i = 0; i < tempString.length; i++) {
      let charNum = tempString.toLowerCase();

      if (charNum <= 122 && numChar >= 97) {
        charNum -= this.shift;
        if (charNum < 97) {
          charNum += 26;
        }
      }
      decryptString += String.fromCharCode(charNum);
    }
    return decryptString;
  }
}

You’ve done research to find out how things work; and you’ve used that to understand what’s going on in the code. That’s good work already. You’re getting there.

let charNum = tempString.charCodeAt(i);
takes the character at index i in the tempString string, and changes that to a number (the ASCII or Unicode value).
For example, for the string "buffalo", the character at index 1 would be 'u' , and the corresponding number would be 117

encryptString += String.fromCharCode(charNum);
takes the number, changes it to a character (again, the Unicode code point stuff)
and adds that character to the string in encryptString

Hi @soph75 !,
Four years ago I joined a bootcamp, one that promised much but delivered little. A bootcamp I’m still paying, haha.

We were supposed to become full-stack developers in three months.

I understand your frustration, because I’ve been there many times. And after some time of trying so hard to be up to the challenge, I had to pause and reset my approach. I faced my coach and eventually the bootcamp management and negotiated an exit. I was just eating up pages and videos of content, tools, frameworks, etc., without really understanding much of what I was doing or why something worked or not. And the value I was getting was not enough to provide some light into my path.

After accepting this, I decided to continue but on my terms. That experience taught me that the road is almost infinite, so I changed my mindset. I now believe that:

  1. It’s ok to spend a lot of time working on the basics. I don’t have to be there jumping around trying all the new tech. Particularly, I’ve invested a lot of time learning javascript.
  2. For each problem solved in a tutorial, there are a couple more variants worth solving. Those variants can test my knowledge to the core. Find some of them and try to solve them.
  3. A marathon mindset is better than a sprint mindset. Yes, we feel the need to go fast, the anxiety, because we need a job, we need to provide for our families, for ourselves. But rushing undermines our good intentions.
  4. Being proficient in a language is not enough, the environment matters too. Here comes the thing about using APIs, methods, etc. As in your challenge, charCodeAt() is an implementation, a part of the environment where javascript lives --not something you will get to through pure logic–. It will be almost imposible for you to think about a solution to a problem using that method in your implementation if you don’t know the method exists. Learning the environment requires both your knowledge about the language and your memory. And memory is built by studying and practicing, again and again.
  5. The main objective is solving a problem, not finding a clever solution.. What to do if you don’t know charCodeAt() ? Is it the only way to solve the problem? Perhaps not. Yes, the solution may not look as nice as this one, but who cares? the client? The client just wants your help, and you’re there to find a way. If I have to create an array like [‘a’, ‘b’, ‘c’, …] and then a kind of weird for-loop to create a shifted array like [‘f’, ‘g’, ‘h’, …] just to have a way to homologate one character for the other, then do the for loop and keep going.
  6. A solution provided by others is not a quality standard. For each clever solution, there might be another one that is better. Don’t judge yourself under the light of the answer of someone else. Instead of losing your time there, learn to read that code, ask yourself what is there to be learned, if possible compare their solution with yours, check documentation, try some code and see how to use this new knowledge to refactor your solution but in your own way of thinking.

Almost 4 years after beginning that terrible bootcamp, I now work as frontend tech lead. The road has been though, but rewarding. Yes, there are still many things to learn, and I still have to face problems everyday that seem unsolvable, but I won’t give up on trying to solve them.

Don’t think I’m a genius for being a tech lead with 4 years of experience. I created my account and started learning on Codecademy almost 10 years ago. My job position is also a result of a set of circumstances that are also unrelated to my abilities. If someone else made it, you can make it.

Hope my path might be helpful to you.

Keep going! You’re just early in the process.

2 Likes