this post was submitted on 29 Aug 2023
10 points (85.7% liked)

General Programming Discussion

7711 readers
1 users here now

A general programming discussion community.

Rules:

  1. Be civil.
  2. Please start discussions that spark conversation

Other communities

Systems

Functional Programming

Also related

founded 5 years ago
MODERATORS
 

I am beginner who thought before doing the String Methods section of the course "You know what, let's test my skills". And boy my skills were tested. After I completed the challenge my jaw dropped, with the solution.

Had/Have this happened to y'all. Where you make something complicated and found out that there was a simple solution?

Solution

My Code

you are viewing a single comment's thread
view the rest of the comments
[โ€“] MrOzwaldMan@lemmy.ml 1 points 1 year ago (1 children)

(For point 1) Got it, from now on variables will be declared with let. I don't understand what is "use strict"; maybe you can explain it.

(For point 2) I was testing to see if reversedWord printed the desired output in the Console, forgot to remove it after finishing the program. I also don't understand what 'O(N^2)' and 'O(N)' is, but +=-ing an empty string is a great idea, why didn't i think of that.

[โ€“] waffle@sh.itjust.works 2 points 1 year ago

"use strict"; is just a way of enabling more restrictions to make writing JS less error prone. You can find the details of what that does on MDN (or, if you don't like long verbose technical explanations, this is a pretty good summary!)