Javascript push() method
The push() method in JavaScript adds one or more elements to the end of an array and returns the new length of the array.
Your task in this problem is to implement the pushAndDisplayArray() function. The function should
- Generate a random number between 0 & 99
- add this newly generated number to the array
- run the renderArray() function to display the array with the newly inserted random number.
- Refer to the screenshots provided below for more clarity.
INSTRUCTIONS:
| Step No |
Crucial Component |
Instruction |
| 0 |
random number(between 0 and 99) formula |
store this random number in any variable |
Math.floor(Math.random() * 100) |
| 1 |
arr.push() |
use the push() method on arr |
arr.push(yourRandomNumberVariable) |
| 2 |
invoke renderArray() function |
invoke the renderArray() function to update the dom with the array with new random number |
renderArray() |
Refer to the intial & final screenshots provided below.
UI reference
On clicking the Push button 1 time
On clicking the Push button 2 times
Evaluation
- After submission, your solution will be evaluated automatically based on the tasks defined above.
- Upon successful completion of all the tasks/requirements, you will get a full score, and there will not be any partial scoring.
- You can work on your failed test cases & resubmit your solution.
- Your problem will get evaluated instantly.
Do’s & don’t
- Use the given code structure in editor and do not make any changes.
- Do not modify existing classes or tags.
- Focus on correct HTML structure and class names.
Query & feedback
- In case of any query/feedback on this project, please fill this form & we will soon get in touch with you to resolve.
Best of luck, developers!