Tell us what’s happening:
I just want to say I find the tutorials very confusing. When I look at the video, its too simple. The instructions do not connect to the task. It’s all I can do to keep going with this but I know if there is a difficult task, doing these will leave be blank. I gues I will be watching a lot of videos.
Your code so far
// Setup
var sum = 0;
function addThree() {
sum = sum + 3;
}
// Only change code below this line
function addFive() {
sum+= 5;
}
// Only change code above this line
addThree();
addFive();
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36.
Challenge: Understanding Undefined Value returned from a Function
This is what I ended up writing because it showed an error below:
var processed = processArg(7);
//return;//It was asking for return but I had to comment it out to get rid of the errors. Guess what, it passed. BUT I DON’T UNDERSTAND IT, I follow the instruction and error messages but in confusion. Return, return what. The previous test did it without return, what does it mean how is it used, why do we need it???
when a function doesn’t have a return statement, it still return something, but as the return value is not defined, it just returns undefined - this is the point of the challenge
meanwhile it makes you write a function that do something but doesn’t have a return statement
what’s confusing you? we can keep for a bit, trying to explain the same think in different ways until you understand. The FreeCodeCamp forum has gone often through these trials and has rarely surrended
Hi, good morning. Okay I get the exercise and have the answer and the tick but here is an example of what I find confusing:
return (num + 3) / 5;
What is the 5 there for. The function is going to run whatever argument you put in +3; why in this example do they add /5. Are they just messing with our brain?
Stand inline now:
Opening paragraph:
In Computer Science a queue is an abstract Data Structure where items are kept in order. New items can be added at the back of the queue and old items are taken off from the front of the queue.
They introduce “queue:” but they are talking about arrays right. This is a disconnect. Why the new terms? This whole coding game is learning new language, throwing in this opening sentence just looses me. Just say we have an array, we are going to add to the end with push and take off the front with shift, or whatever they want to demonstrate.
Now I have just looked at the video, again. He put in “num” and then changes it to item. I put in 6 as in arr.push(6). I didn’t even see we were being told to add 6, it was just the next num in the sequence.
Next I put in arr.shift(0);
But in the video he goes down to the return line to put in the shift - what the…! How we we suppose to know about that.
it’s much easier if you create a new topic for a new challenge! the ask for help button is there to be used
anyway, I know that challenge, you need to add an item to the queue, and then remove and return the first item
queue is language-agnostic, it’s a common usage, this because stuff that communicate through the internet doesn’t have the same instantaneous data processing you can have with everything on the same script, or also with big stuff, processing power needs to be used well, and so one big calculation at a time is done, but many can be queued to be done consecutively, so commands are put in a queue, when one has finished an other one is started.
It’s pretty random, put here like this this challenge you are right. but maybe someone is interested and start searching, or eventually you will find again this topic, and you will remember to have already heard of it
but anyway, think of it as a queue of people, one is added at the end, one is removed from the beginning
you can do this with methods presented so far
the thing about unshift is that it removes an element from the array, but also returns that element
and you must use the function parameters to make your function reusable
Thanks again, I know you are helping. You say it’s common language. I am learning here, I am not a programmer though I have been studying at Khan for three years; my point is this is a site for beginners that’s why we start with the, very basics. FreeCodeCamp seems to forget that half way through the course, we only know what they have covered. It’s no good saying whats common among the programming elite, that’s why I feel stupid , because I have been told you don’t need to know anything to do this course. They never use the word queue in Khan either. Sorry for the rant.
This actually looks like a custom function to me, at least thats what it reminds me of from Khan. And sorry but I don’t know about big processing stuff but at least your explaination now alerts me to the need for the term. A little explanation in the course might help.
Can I just say, I have gone back and looked up return, that helped. I also looked at the video again and again so I understand it there but when I look at the exercise as presented, even though I know how to do it, that leave me completely blank. So I am moving on now.
BTW I continued this topic because you said, “keep asking questions”.
but when you ask a question about a challenge, it’s always nice to the people that try to help you to include your code and a challenge link, the “Ask for help” button does that automatically
anyway the curriculum is going through a great change, also the curriculum try to keep improving