js-mentorship-razvan / javascript

Javascript study notes
GNU General Public License v3.0
22 stars 2 forks source link

Pole Vault Starting Marks #416

Closed RazvanBugoi closed 4 years ago

RazvanBugoi commented 4 years ago

https://www.codewars.com/kata/5786f8404c4709148f0006bf/train/javascript

RazvanBugoi commented 4 years ago
function startingMark(bodyHeight){
  if (bodyHeight == 1.22) {
    return 8.27;
    } else if (bodyHeight == 2.13) {
      return 11.85;
      } else {
        return Number((8.27 + 0.0393333333333333 * ((bodyHeight - 1.22) * 100)).toFixed(2)); } 
}
odv commented 4 years ago

@RazvanBugoi Read the instructions again carefully and let me know after that if you still got issues with this problem.

RazvanBugoi commented 4 years ago
function startingMark(bodyHeight){
   return +(3.4681 + 3.93548 * bodyHeight).toFixed(2);
}

// y = mx + b

// 1.52 9.45   1.83   10.67

// 9.45 - 10.67 / 1.52 - 1.83 = 3.93548

// y = 3.93548x + b

// y = 3.93548 * 1.52 + b

// 9.45 = 3.93548 * 1.52 + b
// 9.35 = 5.9819 + b 

// b=3.4681‬