Skip to content

Commit

Permalink
Merge pull request #2 from tiy-orl/master
Browse files Browse the repository at this point in the history
New Quiz
  • Loading branch information
JCR08 authored Apr 11, 2017
2 parents 6fcfd1a + e3a5434 commit 376faed
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
18 changes: 13 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,21 @@ 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];
let ones = num % 10;
if ((num >= 10) && (ones !== 0)) {
if (num < 30){
return "twenty-" + numbers[ones] ;
}
if (num < 40){
return "thirty-" + numbers[ones] ;
}
}
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 376faed

Please sign in to comment.