There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
You can also find further discussion and get answers to your questions over in Language Help.
Agree with a comment or answer? Like () to up-vote the contribution!
I used Array.Fill when it asked me to set every rating in the ratings array to 0, but it wouldn’t accept the solution and told me to use Array.Clear. Is this just the way it was coded, or is there a specific reason to use Array.Clear for this?
Wouldn’t passing in the length of the array exceed the bounds here? Should it not be ratings.Length-1?
I’m asking only because the hint in the example states “To clear an entire array, set the index to 0 (if it is zero-indexed) and then pass in the length of the array for the third parameter.”.
If we refer to the documentation for the Array.Clear method, we can see that the second parameter of this method is “The starting index of the range of elements to clear.” BUT the third parameter is NOT the index of the last element. Had it been the index of the last element, then your observation would be correct and we would use ratings.Length - 1.
The third parameter of the Array.Clear method is “The number of elements to clear.” So the Array.Length property (ratings.Length in this particular case) is the correct code, as the property gives us the number of elements in the array.
For things like integers, double, strings etc., the Console.WriteLine() method works fine in displaying a text representation. But for certain objects like Arrays, the textual representation displayed by the Console.WriteLine() method is basically a description of the type of the object.
If you do Console.WriteLine(ratings), you will see “System.Int32”
If you do Console.WriteLine(summerStrut), you will see “System.String”
If you want to see the elements of the array, you can try looping over the array.
One way to do so can be
foreach (int rating in ratings) {
Console.WriteLine(rating);
}
Another way could be Array.ForEach(ratings, Console.WriteLine);
Further teaching is needed on this subject. There’s a lot of: “this is how it is,” without explanations. Those of us that need scaffolding (and have never coded anything before) are severely hindered by this variety of lesson. Students that function well in the: “go find it yourself,” method will prosper. Everyone else is utterly screwed. Before anyone says: “How do you expect to code independently if you don’t find solutions,” I’ll say this:
No one can code independently before they are properly taught. I need all of the questions answered before I attempt to apply knowledge I do not yet have. Yes, I can ask questions here, but only after I’m expected to apply principles. It makes me question if I’ve learned anything and/or if I will retain anything I’ve just learned. This lesson is akin to a teacher tossing a text book at a child and saying, “Go learn!” Yeah, we’re probably adults here, but that isn’t teaching. That’s: "go learn"ing. Just some food for thought. I DO have a question though.
Actual Question: Array.Clear(ratings, 0, ratings.Length); <–there is nothing intuitive that would tell me, a newbie, to use ratings.Length instead of the actual # of character positions. Would listing the # of character positions work?
Array.Clear(ratings, 0, 8);
When I code it as such, I still get the correct answer but I am unsure if this is only replacing value 0 and 8, or if it is actually replacing values 0-8.
I understand that ratings.Length would allow users to change the length of the playlist, but earlier in the assignment, we were told it could only have 8 songs. Does this account for if there were only 7 songs?
Thanks for the answers!
I will say one thing: The Codecademy staff is WONDERFUL at swiftly answering questions. 10/10 good teaching there.
I really do not like this specific lesson. Codecadamy has a tendency there is only one way to solve a task and only one.
Yes, I could use Arrays.Copy(). but I could also use the non static method of CopyTo(), which is on the exact same page of the documentation. But it will mark it as wrong.
tasks like these just do not work as intended.
Honestly, this lesson was kinda bad in my opinion. I get that we should get used to reading documentation, but it’s seriously hard to do that whenever the documentation is extremely verbose and just badly organized all around. Maybe it’s just my opinion, but seriously? You’re telling me that Microsoft couldn’t have organized their documentation similar to how W3Schools has their references? Why couldn’t they just get to the point?