You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Neopets are virtual pets that you can play and interact with. The better you take care of them, the happier and healthy they will be!
Create a factory function neopetsFactory() that takes in a name and returns an object.
Objects returned from the function have three data properties, name which is the argument provided, happiness which is initialized to 100 and hunger with is initizlied to 50. There is no min nor max value for happiness and hunger.
Objects returned from the function have three methods: play(), eatVeggies() and eatJunkFood().
play() increases their happiness and also makes them more hungry. This method adds 4 points to happiness and adds 5 points to hunger and returns "Weee!".
eatVeggies() decreases their hunger, but no one enjoys eatting veggies. This method subtracts 6 points from happiness and subtracts 8 points from hunger and returns
An instance of Account has two data properties, owner which is a string and balance which is a numeric dollar amount.
An instance of Account has three methods: checkBalance, deposit, withdraw.
checkBalance takes no parameters and returns a string int he format <owner> has $<balance> in this account.
deposit takes a single number parameters and adds it to the balance property. It should also return a string in the format "$<amount> was deposited to this account."
withdraw takes a single number parameters and subtracts it to the balance property. It should also return a string in the format "$<amount> was withdrawn from this account."
You should not be allowed to withdraw more than what's in the account, in which case, return "Not enough funds." and do not update the balance property.
X: Great implementation of rotating the array. However, you mutated the original array and the problem says not to.
Code Quality
X: rotatedArray could be declared with const. sft is not the best variable name.
Short Response Question X
Technical
X: You did not explain hoisting, but rather, the result of hoisting. Hoisting is not calling a function before its declaration. Hoisting refers to when JavaScript "moves" certain variables and functions to the top. In actuality, it does this by creating space in memory for all variables and functions before running the program. Also, you did not provide a snippet to illustrate variable hoisting.
Directions:
Write your responses to the questions below directly in this document. When you commit and push your changes, you will be able to see your rendered markdown on GitHub.
1. What does it mean for arrays to be passed by reference in JavaScript? Be sure to include a code snippet to illustrate your response.
Pass By Reference refers to the concept of passing the address (reference) to the array. Therefore, if you make any changes to the array inside the function, these changes are saved in memory to the original array. All variables that reference the array, even outside of the function, will reflect the changes since it's bound to the same array in memory.
Directions:
Write your responses to the questions below directly in this document. When you commit and push your changes, you will be able to see your rendered markdown on GitHub.
1. What does it mean for arrays to be passed by reference in JavaScript? Be sure to include a code snippet to illustrate your response.
Answer: Arrays are passed by reference, meaning when an array is initialized, an address of the location of the value of the array that is saved in the heap memory is saved in the variable.
Name the product in a way the reader (i.e. your target customers) will understand. (3+ sentences)
Sub-Heading
Describe who the market for the product is and what benefit they get. (One sentence only underneath the title)
Summary
> Give a summary of the product and the benefit. What are all the things a user can do when use your product? This is the most important section for your readers, so make this paragraph good. (5+ sentences)