Skip to content

Commit

Permalink
Merge pull request #69 from ddsheard/apr10quiz
Browse files Browse the repository at this point in the history
Apr10quiz
  • Loading branch information
bgates authored Apr 11, 2017
2 parents bc36b6d + 72b594b commit 3c1c541
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
17 changes: 12 additions & 5 deletions englishify.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

let numbers = {
0: 'zero',
1: 'one',
Expand All @@ -19,14 +20,20 @@ let numbers = {
17: 'seventeen',
18: 'eighteen',
19: 'nineteen',
20: 'twenty'
20: 'twenty',
30: 'thirty'
}

function englishify(num) {
if (num >= 0 && num <= 20) {
return numbers[num];
if ((num.toString().length == 2) && (num.toString().split("")[1]!= 0)) {
if (num.toString().split("")[0] == 2){
return "twenty-" + numbers[num.toString().split("")[1]] ;
}
if (num.toString().split("")[0] == 3){
return "thirty-" + numbers[num.toString().split("")[1]] ;
}
}
return 'Please enter a number between 0 and 20 inclusive.';
return numbers[num];
}

console.log( englishify(1) );
console.log( englishify(5) );
7 changes: 4 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ <h3>Prime Number Button</h3>
<footer id="copyright">
<p>&copy; The Iron Yard 2017</p>
</footer>
<script src="github.js"></script>
<script src="englishify.js"> </script>
<!-- <script src="github.js"></script>
<script src="prime.js"></script>
<script src="./index.js"></script>
<script src="./fibonacci.js"></script>
<script src="./fizzbuzz.js"></script>
<script src="github.js"></script>
<script src="movementToCoordinates.js"></script>
<script src="euler.js"></script>
<script src="euler.js"></script> -->
</body>
</html>

0 comments on commit 3c1c541

Please sign in to comment.