Using Objects for Lookups.... Food For FCCs Thought

Using Objects for Lookups.... Food For FCCs Thought
0

#1

Tell us what’s happening:

Your code so far


// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
 var lookup = {
    "alpha":"Adams",
    "bravo":"Boston",
    "charlie":"Chicago",
    "delta":"Denver",
    "echo":"Easy",
    "foxtrot":"Frank"
  };
  
  result = lookup[val];

  // Only change code above this line
  return result;
}

// Change this value to test
phoneticLookup("charlie");

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1.2 Safari/605.1.15.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/using-objects-for-lookups

---- I’ve told myself not to bother posting in the forums because it honestly doesn’t seem like anyone actually considers what we say. So this is really pointless, I get that. But why does FCC not provide enough information, context, whatever you want to call it for stuff? If you have to add 500 more challenges to walk us through stuff, do it. If I didn’t just finally result to googling, I would still be trying to figure this out.

You worked us on a couple of object lookup stuff, great, that made sense. The example and instructions were reasonable to the prior learning. Then we get this. You throw a function into it. Are we suppose to use “val” or “result” for the lookup? No, we are suppose to create some new variable, but why? How were we to realize that?

Then we get to the return, that was a little confusing, but then we can realize the techniques from before and reassign result, but if you can’t even understand what’s going on at the lookup, you wouldn’t understand that either.

FCC needs to remember that people here are learning. You can’t just jump into new things when you haven’t fully built a foundation of understanding. How does the “val” get into the lookup? We call the function, and pass in “Charlie” and we are looking for the value (result)… but how is it coming out?

I get that in the “myDog” examples, that myDog.name is going to give me “Fido”. Because myDog is my object and I am targeting the name. Perfect sense. But in this function, you haven’t explained what the heck is going on. At least when it was a switch statement, we were using “val” as the lookup. That made sense. We practiced that.

I know, I totally wasted my time. I just hope FCC would take a look at how they progress us through the challenges and actually think “If I was new, would I understand what is going on?” As I am writing this, the “Your topic is similar to…” section to the right of this has every line with this same problem. Obviously some people are lost. Shouldn’t that be a clue that maybe something needs to be changed?

Im not going to go post on Github. I don’t know why we need to do that in order to be noticed or taken seriously. I don’t need to be given a run around. All I want is for FCC to just think about what people are saying.


#2

---- I’ve told myself not to bother posting in the forums because it honestly doesn’t seem like anyone actually considers what we say.

Because this isn’t where we discuss changing the curriculum.

But why does FCC not provide enough information, context, whatever you want to call it for stuff?

Because FCC is open source and created by volunteers. Also, if they exhaustively went through every topic, it would take 5 years to complete the program and newbies would be put off. Plus, there is some value to having to research. In the real world your boss isn’t going to tell you to do something and then give you a bunch of tutorials on how to do it. I just had a freelance job that had several things that I did not know how to do. So I researched them and figured it out for myself.

If you have to add 500 more challenges to walk us through stuff, do it. If I didn’t just finally result to googling, I would still be trying to figure this out.

“Googling” is exactly would you should do. Good job. FCC is a framework for learning, not an exhaustive step by step that holds your hand each step. Some people need more info on certain topics, some need less.

If you think there need to be some more steps in between, then you are more than welcome to hop onto github and do a pull request.

Im not going to go post on Github. I don’t know why we need to do that in order to be noticed or taken seriously.

Because that is where the people that are actually coding the site are hanging out and discussing these things. This forum is more geared towards people with questions about how to do things.

How does the “val” get into the lookup?

I don’t understand “get into the lookup”.

The variable val is how the function phoneticLookup receives its argument.

function phoneticLookup(val) {

That argument is going to receive the value “charlie” because of how the function is called:

phoneticLookup("charlie");

Are we suppose to use “val” or “result” for the lookup?

The variable val has the key/property we are going to use to get our result out of that object. That is going to return the appropriate value and place it in the local variable result

but how is it coming out?

How is it coming out of the function? We return it with this:

return result;

That returns it out of the function. So, the function call phoneticLookup("charlie"); evaluates to “Chicago” because that is what got returned from the function.

Now, it looks a little odd here because that value just gets lost, nothing is done with it. In real code you’d have something like:

newValue = phoneticLookup("charlie");

or whatever - you’d do something with that returned value.

It sounds like you need a refresher on how functions work. Remember that a function isn’t run until it’s called.


#3

Why don’t you just delete this post. I know how a function is called. Heck… why don’t you actually just delete all of my forum activity. I won’t bother posting here anymore.


#4

I apologize if my answer offended you - I was trying to be helpful. I guess I misunderstood.


#5

I remember talking people through this three years ago on the chatrooms, and talking about whether we could suggest and PR changes to the FCC curriculum improve that and a few other challenges. But that one in particular, it’s extremely difficult to add anything else that explains it any better. It’s fundamentally basic JavaScript, and yes, some people have difficulty with it, as you have, but as @kevinSmith says if every single thing was explained in exhaustive depth no-one would bother with FCC. At some point the curriculum needs to put together two or more of the ultra basic building blocks introduced in previous lessons, otherwise it’s like teaching people the alphabet by spending a lesson on each letter.

No, this is not in any way feasible. “you” in this case is a small group of people who do this in their spare time. Expanding the curriculum massively to cover ultra basic stuff in minute detail means huge amounts more work for them and will have the effect of almost everyone who starts FCC dropping out. You need to be prepared to do a lot if research if you want to do programming, it is a fundamental, basic skill that you need to get good at.