Skip to content

answers to questions - #1

Open
Dmwanik wants to merge 2 commits into
masterfrom
dennis-mwanika
Open

Dmwanik wants to merge 2 commits into
masterfrom
dennis-mwanika

Conversation

@Dmwanik

@Dmwanik Dmwanik commented Apr 5, 2019

Copy link
Copy Markdown
Owner

No description provided.

@Dmwanik
Dmwanik requested a review from byronholmes2018 April 5, 2019 15:49
@byronholmes2018

Copy link
Copy Markdown
Collaborator

objects-arrays.js
lines 10-29. These are not objects. Remember that in JS, objects take the form
const objectName ={ key1:value1, key2:value2, ..., keyn:valuen }

So for instance, if I wanted to make an object 'brontosaurus', I would do something like 
`const brontosaurus = {
     diet: 'herbivorous', 
     weight: '15 tons', 
     length: '22m'
  }`

Lines 32-64, you were trying to access different properties of objects. Since you hadn't actually created any objects, you couldn't access them. In the places you tried, you used something that looked like this:
const Period = function (tyrannosaurus){ return tyrannosaurus.Period; }

There are several problems here. First, the const keyword is used for variables in JS. You started what would normally be a variable name with a capital letter. In JS, the convention is that classes start with a capital letter, and variables start with a lowercase letter. Secondly, you appear to be trying to use a function to access the period of tyrannosaurus. The basic function would work, but because you didn't actually create an object 'tyrannosaurus', you could not return a property 'Period' from 'tyrannosaurus'. (Again, when you do create a property for an object, you should avoid starting the property name with a capital letter.

Request 1 (arrays exercises):
line 85-87. You were not supposed to hard-code an array containing the universities, but rather loop over the provided array graduates, and from each graduate object, access the university property, and push that to an empty array.
line 88: you tried calling a function called 'newFunction()', but you hadn't declared that function anywhere in your code, so when you tried calling it, it couldn't do anything except throw an error.
lines 90-92: this function universities has several problems. The first is you didn't call it anywhere, so even if the function had done what you expected, it wouldn't have been able to actually do anything in runtime. Secondly, if the function was meant to sort the universities in your array, you would have needed a parameter to accept the array. According to your explanation yesterday, the parameters a,b were placeholders for strings. If you don't have a parameter for the array, you cannot loop over the array to ensure your function is being applied to all the strings in the array. Finally, it is still unclear to me how your return statement would actually accomplish the sorting of strings, since you didn't include logic for handling the returned value from the nested ternary operators to ensure actual sorting occurred. Also, for complex things like sorting, at this stage in your programming journey, I'd recommend looking at built-in functions before attempting to write code. It saves time and allows you to be more productive.

Request 2:
You hard-coded the array that was supposed to be generated by looping over the array 'graduates' and performing operations to access the needed properties of each object in that array.

Request 3:
You initialized an empty array, and then tried to invoke the array on an object 'sort', which wasn't declared anywhere. Again, to achieve this objective, you were required to loop over the provided array 'graduates', and use your knowledge of arrays and objects to access the required properties, which were supposed to then be concatenated into a string, which would be pushed onto a new array.

- advanced array methods

None attempted.

Request 4.
prototypes.js
-not started

classes.js
-not started

functions.js
-not started

MVP not complete. 1

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

Successfully merging this pull request may close these issues.

2 participants