I’ve gone through 10 of the basic bonfires, and I’m not sure if I’m doing everything correctly. I don’t know if I’m going through them too fast.
I’m going to discuss specific examples here, so if you haven’t gone through the bonfires and don’t want hints, don’t read further.
-
The first thing I do is take the recommended things to look up and look them up on w3 instead of MDN. I find it easier to understand.
-
I’m not looking up solutions or trying to google the challenge as a whole, but I might google a part of the challenge. For instance, on the checking for palindromes challenge, I realized one step in my process would be to remove special characters and spaces. When I first tried it, I got rid of only the first space. I did googling to find that I could do add the /g for global and get rid of all the spaces. Further googling and I found the character class that got rid of everything except underscores (/\W/gi) and the chaining technique for getting rid of all of them at once. I think I found that information on stack overflow. My line of code for this part of the challenge came out as:
var noSpace = str.replace(/ /g, “”).replace(/\W/g, “”).replace(/_/g, “”);
My approach to the challenge came from my head. ( 1. Remove spaces and special characters 2. convert to lowercase 3. create an array 4. reverse the array 5. join the array to a new string 6. if new string === old string, true else false)
Did I get too much help on this one?
In general, my approach is to break the concept into small steps, and if necessary look up methods that do the steps I’m after. Another thing I found from googling was Math.max(…array). I googled how to find the largest value in an array, after I had created an array of the word lengths on the find the longest word in a string challenge.
So basically I’m wondering if I’m doing too much looking up or if this is an appropriate amount of looking stuff up for my level.
- I’m not even really trying to understand recursive functions right now. I’m doing everything with loops. I’m also not particularly concerned with elegance of my code. Is this a problem at this stage?
Any help is appreciated. I just want to make sure I’m not missing the point of the exercises.