This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Solution written in PHP: | |
class CSVProcessor { | |
private $data = []; | |
public function readCSV($filename) { | |
$handle = fopen($filename, 'r'); | |
if ($handle !== false) { | |
while (($row = fgetcsv($handle)) !== false) { | |
$id = $row[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Droid { | |
private String name; | |
private int batteryLevel; | |
public Droid(String droidName) { | |
this.name = droidName; | |
this.batteryLevel = 100; | |
} | |
public String toString() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Write a function groceries() that takes an array of object literals of grocery items. | |
The function should return a string with each item separated by a comma except the last two items should be separated by the word 'and'. | |
Make sure spaces (' ') are inserted where they are appropriate. | |
groceries( [{item: 'Carrots'}, {item: 'Hummus'}, {item: 'Pesto'}, {item: 'Rigatoni'}] ); | |
// returns 'Carrots, Hummus, Pesto and Rigatoni' | |
groceries( [{item: 'Bread'}, {item: 'Butter'}] ); | |
// returns 'Bread and Butter' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const team = { | |
_players: [{ | |
firstName: 'Pablo', | |
lastName: 'Sanchez', | |
age: 11 | |
}, | |
{ | |
firstName: 'Emilio', | |
lastName: 'Rodriguez', | |
age: 12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const name = 'Nala'; | |
const getRandEvent = () => { | |
const random = Math.floor(Math.random() * 3); | |
if (random === 0) { | |
return 'Marathon'; | |
} else if (random === 1) { | |
return 'Triathlon'; | |
} else if (random === 2) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const menu = { | |
_courses: { | |
appetizers: [], | |
mains: [], | |
desserts: [], | |
}, | |
get courses() { | |
//return Object.entries(this._courses); | |
return { | |
appetizers: this.appetizers, |