Hello from a Newbie (Just figured out The Stand in Line Challenge)

Hi everyone! Just wanted to introduce myself here. I signed up only a few days ago, but have been hooked on freeCodeCamp. Learning to code has been on my to do list for many years, but other interests, kids, life in general, and procrastination on my part has made me put if off for years.

Anyway I just figured out The Stand in Line Challenge and wanted to offer a little bit of advice to anyone else similar to my situation. I have very basic knowledge of HTML and CSS, I took a C++ class during my college days which was over 10 years ago! I was cruising through the challenges feeling pretty good and able to figure things out pretty quickly right until I got to The Stand in Line Challenge, I was getting frustrated because I really had no idea what I needed to do. I took a break and then decided to look for something to help me grasp the very basics of JavaScript, because I could get through the earlier challenges fine, but I wasn’t really remembering the concepts of arrays and how to manipulate them.

I found a book on Amazon called A Smarter Way to Learn JavaScript by Mark Myers, (In truth I downloaded a book called JAVA Crash Course, then realized that JavaScript and JAVA aren’t the same lol, just goes to show how much of a beginner I am). Anyway I know this book may be way too simplified for others but it helped me a ton and I thought others might be in the same situation as me. The part that really helped me was after each chapter it has really simple, almost seems too easy online exercises but the explanation and repetition helped me greatly grasp the concepts better.

Also here is my code from the challenge, if anyone has any pointers or suggestions on improving I would greatly appreciate it. Thanks, I look forward to meeting everyone here :slight_smile:

function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  var removedNumber = arr.shift();
  
  return removedNumber;  // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
11 Likes

Hey Congratulations finally for starting “Learning to Code” and joining an amazing community here.
Your code looks good. Just remember “Learning to Code” is easy and is also difficult.It’s enjoying and boring(may be sometimes), it will make you feel delighted and sometimes it will make you feel crushing.
In each of these situations we have to remember just one thing, keep the end result in your mind(why you are learning to code) and just “KEEP GOING!”.

5 Likes

Thanks Faizahmadfaiz, I agree with everything you said, I know the hard part will be to stay consistent, even after a few weeks/months. That will be the hard part.

2 Likes

Your code looks good, but just a little FYI, if you want to paste code to the forum, use triple backticks(`). See this post for more details.

Good luck with learning to code!

2 Likes

JavaTheNutt, thanks for that tip, definitely looks better that way :slight_smile:

1 Like

Hi! I just had to go into your post and make a quick edit. I added spoiler tags around your solution in case someone wasn’t expecting to see an answer in this thread. It’s still visible to anyone interested - all they have to do is click on it to unblur. In the future, you can do this yourself by surrounding your code with these tags

[spoiler]
// code here
[/spoiler]

Happy coding!

2 Likes

Oh wow @PortableStick that is awesome, thanks for doing that, I didn’t know it was an option.

Hey @blueskylove77 . Would mind to elaborate in your thought process to get to the answer? Thanks :smiley:

1 Like

Thanks. I got stuck with this too. Now I solved it, thanks to you.

Hi, blueskylove77! Thank you so much for the tip of the book. I needed a book to teach me the basics of the basics. I feel running after a train at high speed. I’m never inside the train, always behind. I see you left this message over a year ago, but it’s being precious to me right now. Thank you!