Hi Everyone! I’m Dakota Lee Martinez. In this video series I’ll be using the Hacker News API to build out a Hacker News Clone in AngularJS.
These videos are accompanied by a series of blog posts at becomingaprogrammer.com. You can find the written explanation of the process and code samples there.
This video covers the following topics:
* adding a pluralizeTime function that takes a time (number) and a timeUnit (string) as parameters. Examples: pluralizeTime(1, ‘hour’) … ‘1 hour ago’, pluralizeTime(2, ‘hour’) … ‘2 hours ago’
* calculating time windows (in seconds) that we’ll use to display different time units depending on how long ago the post was created.
* creating multiple if/else if statements corresponding to these windows and storing the value of the number of each time unit within each block.
* using the pluralizeTime function and passing the rounded down version of the value stored in the previous step with the proper time unit.
* reloading http://localhost:8080/#/post?id=1 to see the new output of 9 years ago instead of 86000+ hours ago.