Anyone else find this challenge difficult?

Anyone else find this challenge super difficult to do? I feel like I’ve just climbed Everest and wrestled with a JavaScript Bigfoot bear! It took about 30-40 minutes of trying to break down every little bit.

I love fCC, but it does kind of skim over a lot things. Or at least that’s how I feel. I wonder what everyone else thinks?

Code

function nextInLine(arr, item) {
// Only change code below this line
arr.push(6)
return arr.shift();
// Only change code above this line
}

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

// Display code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6));
console.log("After: " + JSON.stringify(testArr));
Challenge Link

Challenge: Stand in Line

Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/stand-in-line

2 Likes

I’m not sure what may have been skimmed over? The use of push and shift are covered. The challenge intentionally doesn’t tell you which two methods to use. They describe a desired behavior and you need to look up the methods that provide that behavior. We’re trying to build up to solving real problems that don’t tell you exactly what code to write.

1 Like

you’re supposed to return the removed number (1), but i’m not sure if you knew this and are just playing with the code above.
i felt like fcc was skimming some stuff in the js section so i bought a thick book on the subject with qualitative descriptions of everything, but i javen’t used it much as i found things come to me with practice (projects are good for that and also the interview prep section).
just go with the flow and fcc do a good job of steering you the right way imo. it just comes to you sometimes later than expected.
(i’m through the web design and into the front end stuff now and it’s less like that. i think the content in js is more esoteric)

1 Like

FCC is not comprehensive - it does not cover everything. And it doesn’t re-cover things it has already covered. The danger of either of those things is that the curriculum would become boring and repetitive.

Yes, there are a lot of points where one says, “crap, I don’t remember learning this…” But in some ways that is a good thing - a big part of being a coder is having to look things up. No one can remember all of this stuff. As a professional dev, I have to google things or check stack overflow or look in docs at least 10 times a day. I’d be willing to bet that there are days that are 4X that.

In the real world, you don’t get told what tools you need to solve something. You don’t just happened to have completed a conveniently useful tutorial before starting. You have to have an idea what is available and be able to google the details.

2 Likes

It might be helpful if you explained what you found confusing and what part of the challenge that you wanted to be explained better.

I do think the two hints from the hints page might be incorporated into the challenge, or if nothing else just hinting at “useful array methods”.

1 Like

What I love about all of your comments… is how you haven’t shut down this conversation. I think I especially respect the experienced devs for not dismissing out of hand my (albeit very minor) issues with fCC.

This is a sample of what I wrote for this task, in order to help me understand it and I think this kind of thing might be helpful for some learners like myself (assuming the info is correct and I’m not saying I got everything 100%!) who are really just trying to orientate themselves in the new world of JavaScript.

My notes for Standing in Line
function nextInLine(arr, item) {

arr.push(item);
return item;
}

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

console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6));
console.log("After: " + JSON.stringify(testArr));

Looking above we can see that

There is a variable called testArr = [1,2,3,4,5];

(“Before: “ + JSON.stringify(testArr)); reads out the initial state of the variable onto console.log

A function has been declared and named nextInLine

The nextInLine function has parameters in parenthesis (arr, item)

The nextInLine function will take place

Non-specific parameters (arr, item) have been replaced by specific parameters (testArr, 6)

The function instructs the console to push the item parameter (6) on to the arr parameter (testArr). By this point the console.log returns

This is because the function is simply returning the item as it is after the first event, but we want to remove the 1 from the return…

function nextInLine(arr, item) {

arr.push(item);
return arr.shift();
}

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

console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6));
console.log("After: " + JSON.stringify(testArr));

Now the function has been altered slightly so that the arr parameter (testArr) has the 1 removed using the .shift() instruction.

Two main events take place in this function before returning the “After: “ + JSON.stringify(testArr));

When we call the function our console.log returns

I think you understood the instructions.

But my question is, did you need to look at the hints page to know which array methods to use? Was it unclear that you would need (I guess it isn’t strictly needed) to use push and shift?

I’m just wondering if the challenge should refer back to previous “Manipulate Arrays” challenges, or just hint at using array methods previously taught. I believe we do that in other challenges as well.

1 Like

The hints helped a bit and so did the video, but even then I struggled. It’s one thing to pass a test, but another to understand what’s going on… By the way I have no problem with googling for answers. Having said that, JavaScript is a new language with a new syntax.

Having each sub task laid out is very helpful for me and I imagine it would be helpful for others who find everything moving a little to quickly. I feel like the process of building each formula per lesson is taken for granted. All of the principles are taught and information conveyed but how each formula is built per lesson is kind of left unexplained. For beginners, I believe it might be helpful to explain each formula for every lesson.

This could be optional and of course no one has to read this, but it would help people get a firmer grasp of the principles of building a Javascript function or rule etc. The point of each lesson gets a bit lost when other parts are not clear (in the learners mind). This is why I broke it down as much as I could. It helps me and it might perhaps be helpful to others.

So that was my specific point really, but I do want to reiterate how awesome fCC is. I also love the forum and all the people here. Thanks for indulging me.

Learners need to be weaned off of step by step instructions that don’t require any thought though. We aren’t going to nail the timing on how fast we do it, but it has to happen somewhere in the curriculum. And this transition from replication of simple instructions to problem solving seems to me to be the essence of becoming a programmer.

It’s good that you’re using the forum. The forum helps us ease the transition for people where our weaning off explicit instructions comes a bit too fast.

2 Likes

Yeah, I’ll second that. In the “real world” there are very rarely step-by-step instructions. Heck, I just spent more than a week reading through poorly written documentation and sparse articles, trying to implement a couple stubborn libraries that we needed for work. I would have killed for step-by-step instructions.

A big part of being a dev is looking things up and figuring things out. It’s usually not as bad as my last week was, but very rarely is it just stream of consciousness coding without looking things up or searching things. And almost never are there step-by-step instructions.

Yes, this is tough. If it were easy, high school dropouts would do this job and it would pay minimum wage. Be glad that it’s difficult.

1 Like

You are an experienced dev and so I totally bow down to your expertise, and I get where you are coming from. I think you are totally right and yet I feel like JavaScript is an established language. Teaching the grammar of it shouldn’t be sold short. I imagined problem solving to come later. This part of fCC JavaScript is more about the nuts and bolts of the language. The tools of JavaScript. It doesn’t make much sense (to me) not to teach the grammar aspect at the same time. But knowing that you just had an awful week with badly written documentation does make me feel a bit better :rofl: Thanks Kevin

1 Like

I can see where you are coming from with the grammer comparison, but I’m not sure how well it compares. The rules for combining the elements of a programming language’s syntax to produce a series of logical steps to accomplish a task are really flexible. It is less a grammar and more a… I don’t know what.

There are courses on design patterns, but that’s more of an advanced problem solving topic. I’m not sure that there is a ‘right’ way to teach logical problem solving for code when first learning to program. The best I’ve seen is to present larger and larger problems and to be available if the learner gets stuck. :man_shrugging:

1 Like

I really don’t think that it is. Yes, it moves quickly, but then, as said, if we drilled down into each thing and taught them exhaustively, the JS section would be 20 times as long and no one would complete it - they’d all quit out of boredom. The problem is that different people will have different sticking points. You can’t guess every possible sticking point so you’d need an exhaustive curriculum. That’s just not feasible.

I still think it is a better approach to teach the basics and expect people to do their own searching. “Read - Search - Ask”.

Yeah, I think grammar and syntax comparisons break down at some point. The concepts or these are much simpler in coding. They are important and strictly enforced and the “listener” can’t really infer things the way a human listener can with human language, but in many ways it is much simpler.

1 Like

Thanks for this insight Jeremy! Well if nothing else I’m quite stubborn and willing to learn so maybe that will push me in the right direction haha

Stubborness and time will get you pretty far.

The challenge is pretty clear: add item to the end of the array and remove the element from the beginning of the array. You are allowed to use item to hold value to be returned. You just need to decided which array functions will do the job.