Skip to main content

Entangled Strings - Some JavaScript wisdom for when you get entangled

I get these Strings entangled sometimes. You gotta know your stuff well enough to speak to computers these days. They don't argue with you. They just do as you type, maybe say in some cases.
Let us debug πŸ‘©πŸ½‍πŸ”§
str.charAt(index) !== str[index] in some cases and here's why:
str.charAt(index) returns "" if no character is found at the given index BUT str[index] returns undefined instead.

Do you even know what to do when you find me?
This never logs because I am at position 0 and that's falsy. All you had to do was check for negative vibes. Now, you know I only do positive vibes yea?😏

Let's try this again.
We found her!
This logs because I check for negativity instead. Using str.indexOf(searchValue) means to expect -1 when the search value is not found or a value >= 0 when it is found.

Now, I know you heard stuff about str.substring(2) === "POSSIBLE" being true. Yes, POSSIBLE is in fact a substring of IMPOSSIBLE. Hence, the motive to tweak impossible situations. Don't try it with Strings in JavaScript. Strings can't be changed in JavaScript because they are immutable. So, the code below not working has nothing to do with my father not wanting my name changed but everything to do with the fact that JavaScript won't just let you mess with a QueenπŸ’ƒπŸΎ.
Now that you know facts don't change. Feel free to open your console. Cheers!

Comments

Post a Comment

Popular posts from this blog

Wrapping Up Internship

Wrapping up internship ... Unwrapping Contribution The one fear I had about the internship was not making it past the first month. Not only did this not come true but I made it till the end of the internship. The amazing thing that happened during the internship was the sudden boost in my self-esteem. Outreachy internship helped me improve on my communication skills through my mentors; who are my accountability buddies and managers . It was easy to communicate progress, blockers, and feedback. The internship helped grow my debugging and problem-solving skills through blockers.πŸ˜… I always tried debugging issues while awaiting help from my mentors. I would go ahead with other tasks and take short breaks to debug...see if I'd catch something new.☺My coding skills did improve as well, through study (code learning and online learning) and practice. My mentors also had me explain my code sometimes to be sure that I understood what I was writing. My Outreachy mentors helped me g

Modifying Expectations

It is very fine to modify your expectations... Initially, the estimated and actual completion date for my internship project was not specified. Resource estimates had 100 to 200 hours for writing the tests. So far, I have been able to meet some goals. Some of them include me being able to: learn the existing codebase test some success and failure scenarios for the edit , protect , rollback actions learn the basics of integration testing learn how to write tests using mocha learn the basics of the chai assertion library learn some vanilla javascripts fundamentals In the first half of my internship, I have been able to accomplish the goals listed above plus some extra learnings like:  Promises, async/await concepts technical writing team work open source contribution Setup took longer than expected but the progress since setup improved greatly. It took way longer than expected because I had no understanding of  docker  and some other technologies needed for setup