Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Spoiler Code for Lesson Review Record Collection #16

Closed
SaladBarBreath opened this issue Jul 28, 2016 · 3 comments
Closed

Issue with Spoiler Code for Lesson Review Record Collection #16

SaladBarBreath opened this issue Jul 28, 2016 · 3 comments

Comments

@SaladBarBreath
Copy link

On the page Lesson Review Record Collection the spoiler code and the hints does not create the empty array needed before adding the new value to the nested object properties. Adding in collection[id].tracks=[] in the else if (prop!=='tracks') fixes this.

So the function should look like such:

function updateRecords(id, prop, value) {
 if (value===''){
   delete collection[id][prop];
 } else if (prop !== 'tracks') {
   collection[id].tracks=[];
   collection[id][prop] = value;
 } else {
   collection[id][prop].push(value);
 }

  return collection;
}

@codercodingthecode
Copy link

Yes, that fixed the issue. However, shouldn't that be treated in a specific else if as the problem ask too?

I started with something similar to this and it did work on my manually cases.

if (prop !== 'tracks' && value !==' ' {}
else if (prop === 'tracks' && value !==' ' {}
else if .......etc

@Rafase282
Copy link
Owner

I'm going to redo the whole thing as it has been updated and people have no noticed that my solution is for an older version.

I took a look and the challenged was updated. I always provide a copy of the instructions that I followed when solving the problem precisely for this case, I knew I would not be able to know when a challenge was changed so people would be able to check if my solution is for the latest version or not.

@Rafase282
Copy link
Owner

Here is my code 9e6358e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants