• Image placeholder
  • 홈 페이지
  • 블로그 센터
  • 범주
Image placeholder

Math.floor

Math 메서드로 랜덤하게 배열의 요소 가져오기

그 중 하나 많이 쓰는 것 Math.random() = 0에서 1 사이의 수를 가져온다. 0 에서 10 사이의 숫자가 필요하다면? Math.random() * 10 하면 된다. 하지만 소수점 자리도 필요가 없으니까 소수점 자리는 버려주는 몇가지 방법이 있다. 1. Math.round() 반올림해주는 메서드 1.1 ~ 1.4 = 1 로 반환 1.5 ~ 1.9 = 2 로 반환 2. Math.ce...

Math.roundmathMath.randomMath.floorMath.ceilMath.ceil

JS100 평균점수 구하기 parseInt, Math.floor

공백으로 구분하여 과목의 점수가 주어지면 전체 평균 점수를 구하는 프로그램을 작성하세요. 단, 소숫점 자리는 모두 버립니다. 입력 : 20 30 40 출력 : 30 prompt로 입력받은 숫자는 문자열로 본다. 그래서 0 + 34 + 34 + 34 = 0343434 이렇게 된다. parseInt(scores[i], 10) -> 십진수의 형태의 숫자로 데이터 타입을 변환함. Math.floor...

Math.floor제코베parseIntJS100JS100

© 2022 intrepidgeeks.com

Privacy Policy Contact US Sitemap
🍪 This website uses cookies to ensure you get the best experience on our website. Learn more