Jump to content

javascript help creating this program

Nipplemilk909

i need help with this program.

im really trying not to learn js just trying to get through this class  

Create a file called index.html and a file called min-max.js. In min-max.js create a class called MinMax.

This class should have the following:

constructor(numbers) // constructor should store an array of numbers in a member variable called numbers

findMinMax() // this function returns an array that holds the minimum and maximum values of numbers. (You can use the code from the previous assignment to help with this)  

removeMax() // this function removes the first instance of the maximum value in numbers and returns the numbers member variable. Example: numbers = [3,9,0,1,7,9]. After this function is called numbers = [3,0,1,7,9]

 

In your index.html file link min-max.js. Add javascript that instantiates a MinMax object and call findMinMax() and removeMax() on the object and log the results to the console. Do NOT use the array sort method or any pre-written min and max javascript functions to solve these problems.

Link to comment
Share on other sites

Link to post
Share on other sites

It's pretty simple. Just did it in 20 minutes while watching the Dodgers game. I wrote the first function for you since it sounds from the prompt like you should already have the logic for finding the minimum and maximum. The other function I put in place, and provided you with links where you can read up on how to write the super simple logic. It can probably be written in about 5 lines.

 

https://gist.github.com/MCDELTAT/de15241be67d08cd1bbd7a3df2aebdda

 

It's always fine to ask help, but honestly you should just learn the topic. If you don't want to learn then why are you in school?

Link to comment
Share on other sites

Link to post
Share on other sites

42 minutes ago, MCDELTAT said:

It's pretty simple. Just did it in 20 minutes while watching the Dodgers game. I wrote the first function for you since it sounds from the prompt like you should already have the logic for finding the minimum and maximum. The other function I put in place, and provided you with links where you can read up on how to write the super simple logic. It can probably be written in about 5 lines.

 

https://gist.github.com/MCDELTAT/de15241be67d08cd1bbd7a3df2aebdda

 

It's always fine to ask help, but honestly you should just learn the topic. If you don't want to learn then why are you in school?

thank you! you are a god, i understand the concepts of methods functions, classes loops at a minor level from other langues like python and c++ but i really dont want to learn java script syntax right now,

Link to comment
Share on other sites

Link to post
Share on other sites

On ‎02‎/‎11‎/‎2017 at 4:01 AM, Nipplemilk909 said:

thank you! you are a god, i understand the concepts of methods functions, classes loops at a minor level from other langues like python and c++ but i really dont want to learn java script syntax right now,

syntax is not much different than most other languages. its very simple, not quite python simple but better there.

 

On ‎02‎/‎11‎/‎2017 at 4:01 AM, Nipplemilk909 said:

thank you! you are a god, i understand the concepts of methods functions, classes loops at a minor level from other langues like python and c++ but i really dont want to learn java script syntax right now,

 wouldn't it be easy to just push to an array if that number isn't already there? 

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×