Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jendiamond/coding_for_product
https://github.com/jendiamond/coding_for_product
Last synced: 7 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/jendiamond/coding_for_product
- Owner: jendiamond
- Created: 2017-06-02T23:27:42.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-06-09T00:20:17.000Z (over 7 years ago)
- Last Synced: 2024-10-09T01:40:23.477Z (about 1 month ago)
- Language: Ruby
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Solutions for the Coding for Product [Coding Exercises](http://codingforproduct.com/coding_exercise)
These solutions are done in Ruby 2.3.0### Run the Ruby code
#### coding_for_product$ `cd ruby`
#### coding_for_product/ruby$ `ruby codingforproduct_class.rb`### Run the tests like this:
#### coding_for_product/ruby$ `ruby test/codingforproduct_test.rb`---
### Exercise 1
+ Write a function that when given a key value pair with a title and url
+ The function will print a linked title
+ If the title is longer than 50 characters
+ Truncate the title to 50 characters followed by 3 ellipses
+ Print using the print/console method from your programming language#### Input:
This is a Javascript Object. Your input will differ depending on the language you use.
```
{
title: 'really, really, really long title that will be chopped off',
link: 'example.com'
}
```#### Output:
```
really, really, really long title that will be cho…
```---
### Exercise 2
Write a function when given an array of key value pairs, the function will print out a linked title for key value pair. Call the function from previous question in this function.#### Input:
This is a javascript Array of Objects. Your input will differ depending on the language you use.
```
[
{title: 'Github',link: 'github.com'},
{title: 'Google',link: 'google.com'},
{title: 'really, really, really long title that will be chopped off',link: 'example.com'}
]
```
#### Output:
```
Github
really, really, really long title 3 that will be ch…
```