Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSAMUEL LAWRENCE
Courses Plus Student 8,447 PointsStudent record search challenge
Hi guys, this is a long one. I just completed the JavaScript loops, arrays and objects course. We were asked to create a search engine for the student record database we created in earlier videos. I have a bunch of questions.
Video link: https://teamtreehouse.com/library/the-student-record-search-challenge-solution
- in the first
if
statement inside thewhile
loop. Dave McFarland wroteJavaScript if (search.toLowerCase() === search) { };
video time: 01:23
In the second if
statement insdie of the for
loop he wrote;
if (student.name === search) { } ;
why didn't he write
if (search === student.name) { } ;
like he did in the first if
statement?
video time 04:16 and 05:29 He created a function that he passed a student object to. How do we know or decide we need a function? Was it absolutely necessary to create a function? How can you tell you're going to need a function? Why did he create a function and passed a student object to it? He didn't really explain the need for or his reason for deciding to use a function.
After he created the function which he named
getStudentReport
he passed an argument ofstudent
. When he called the function later at 05:29, in theif
statement inside of thefor
loop inside of thewhile
loop he passed an argument ofstudent
. is that the samestudent
inside of the function he created or is it thestudent
variable at the top of the file?For the message variable inside of the
for
loopif
statement why didn't he use+=
when he had already created themessage
variable at the top and now he was adding to it? Why did he only use=
? I tried using+=
but it stacked the search results on top of each other in the browser. It didn't change the previous search and showed the new search. So after a while all the results I got when searching were display. Why is it doing that when I use the+=
?In the
student.js
file the first letter of thename
property is capitalized. When searching if I don't capitalize the first letter, then no results return. How can I capitalize the first letter of a string? Dave didn't cover that in this course. Only `toLower/UpperCase.
3 Answers
SAMUEL LAWRENCE
Courses Plus Student 8,447 PointsAndrey Misikhin I really don't appreciate you telling me I don't want to understand this on my own, you have no idea how many time I spend each day trying relentlessly to understand this, I spend days working on a challenge, going over my meticulous notes, and rewatching videos, which I've downloaded for easy access, before ever posting a question. When I post a question, it's because in my opinion, I've exhausted every other means of solving the challenge. I also spend lots of time on CSStricks and stackoverflow looking for help. If you find my questions dumb or nonsensical please you can choose not to resopond, but please don't tell me I'm not trying to understand things on my own. People learn at different rates. Please understand that.
Thanks.
SAMUEL LAWRENCE
Courses Plus Student 8,447 PointsAndrey Misikhin . Thanks for the reply again. FYI you don't need to learn how to make bricks to build a house, but I get your analogy, and honestly bro, I spend a lot of time working a problem. I'm really just an annoyingly slow learner. Sometimes I spend the entire day tackling just one problem, just to assure myself I really gave it all I had based on what I know. I also look up a lot of these problems on other sites. But many of the explanations come from people who's been doing this for years. I only just started this 2 months ago. So a lot of the terminologies are still pretty new to me and the jargons the other students use sometimes confuse me more. But believe me, I do try, hard. At times my head literally hurts man. And I also rewatch videos and my meticulous notes. I even read the video transcripts just in case I didn't hear something correctly.
But really thanks for taking the time to look and try to answer my question. I'm not giving up on this. I enjoy it and I know the future lessons are building on the first. So I'm doing my darnest to get it.
Andrey Misikhin
16,529 PointsYour questions for the most part say that you do not want to understand things by yourself.
- No difference. From the permutation of the terms, the amount does not change, this is passing at school.
- Functions structurize code. You may not use them, but then it will be difficult to read and understand your code. And you can reuse blocks of code so many times as you want without duplicating.
- Repeat what functions are and how they work.
- Why? He want to show only one message.
- For that reason you need .toUpperCase(), .toLowerCase() at your discretion. And, yes, it was covered, so why you just don't want to use it? You want to lower only first sign of a name, but if someone typing "JoHn", is your program showing anything?
SAMUEL LAWRENCE
Courses Plus Student 8,447 PointsHI @Andrew Misikhin The reason I'm asking these questions is because I want to understand. Some of us are slower at getting things, especially new things than other. Even Dave said it was a difficult challenge. Secondly I didn't understand any of your answers. And you used terms I'm completely unfamiliar with, like functions structurize code and permutation of the terms. Finally for the .toUpperCase and . toLowerCase I only want to change the first letter of the string. I've watched these videos repeatedly and no, he did not mention how to change only the first letter to upper or lowercase of a string. Again, people learn at different rates. Please try to understand that. I tried many things and wrote the areas I'm having difficulty with and tried to cearfully phrase my question. I'm doing it cause I don't understand these areas and need help. Not because I'm trying to be difficult or because I don't want to learn. I spent money to do this course, that should say that I actually do want to learn, but this is all new to me and I'm having diffiulty. please don't judge me. Thanks a lot for your response anyway. much appreciated, but I didn't understand it.
FYI I spent several days, like I always do, on this before opting to post this question in the forum. I do try. I spend at least 5 hours a day, each day including sunday, about 3 hours, trying to learn this.
Andrey Misikhin
16,529 PointsAndrey Misikhin
16,529 PointsOk, sorry, I understood. I am a student like you, not a teacher, maybe, therefore I gave you such answer. I think, if you didn't understand, for example, how functions work and why teacher uses function parameter inside function, than you need to repeat this material until you understand it, because next tasks will be more difficult and they are builded of basic blocks, that you must understand before use it. More simply, you can not build a house until you learn how to make bricks.