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

数组最大最小值 #41

Open
zhn4 opened this issue Jun 20, 2018 · 0 comments
Open

数组最大最小值 #41

zhn4 opened this issue Jun 20, 2018 · 0 comments

Comments

@zhn4
Copy link
Owner

zhn4 commented Jun 20, 2018

demo
http://jsbin.com/kerisasobo/edit?js,console,output

var arr = [11, 2, 44, 24, 5, 9, 10]

// 数组最大值
var max = arr[3]
arr.map((item) => {
  if(item > max) {
    max = item
  }
})
console.log(max)

// 数组最小值
var min = arr[3]
arr.map((item) => {
  if(item < min) {
    min = item
  }
})
console.log(min)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant