A Pen by felix

Thumbnail
This awesome code was written by f1e2l3i4x5, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright f1e2l3i4x5 ©
  • HTML
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>A Pen by  felix</title>
  
  
  
  
  
</head>

<body>

  
  
  

    <script  src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/f1e2l3i4x5/a-pen-by-felix-aVEyzr */
function golfScore(par, strokes) {
  // Only change code below this line
  var answer = '';
  var diff = par - strokes;
  switch (diff) {
    case 2: 
    answer = 'Eagle';
    break;
    case 1': 
    answer = 'Birdie';
    break;
    case '0': 
    answer = 'Par';
    break;
    case '-1': 
    answer = 'Bogey';
    break;
    case '-2': 
    answer = 'Double Bogey';
    break;
    case '-3': 
    answer = 'Go Home!';
    break;
  }
  
  if (strokes==1) {
    answer = 'Hole-in-one!';
  }
  
  
  return answer;
  // Only change code above this line
}

// Change these values to test
console.log(golfScore(4, 2));

Comments