---
# System prepended metadata

title: Elofun Fresher Javascript Test
tags: [ALGORITHYM, PARSING, FUNDAMENTALS, STRING, UTILITIES, ALGORITHMS, FUNDAMENTAL]

---

# Elofun Fresher Javascript Test 
Welcome to Elofun. Our vision is to bring fun to every moment that users spending in the ditigal world. We have our game in Myanmar which has 70K DAU and we are expanding it to different countries. We hope that your talent could help us to achieve our goal.
You have **ONE DAY** to complete this test in **JAVASCRIPT**. We hope that you can prove your skill. Good luck!
**Submit your result:** You could share it in https://codepen.io/ or *github*. Ensure to give us the permission to view.
## Question 1
In this question, you will remove the left-most duplicates from a list of integers and return the result.
```javascript=
// Remove the 3's at indices 0 and 3
// followed by removing a 4 at index 1
solve([3, 4, 4, 3, 6, 3]); // => [4, 6, 3]
More examples can be found in the test cases.
```
###### tags: `FUNDAMENTALS`
## Question 2 - Point in Polygon
#### The problem
In this question, you're going write a function called pointInPoly to test if a point is inside a polygon.

Points will be represented as [x,y] arrays.

The polygon will be an array of points which are the polygon's vertices. The last point in the array connects back to the first point.

You can assume:

1. The polygon will be a valid simple polygon. That is, it will have at least three points, none of its edges will cross each other, and exactly two edges will meet at each vertex.
1. In the tests, the point will never fall exactly on an edge of the polygon.
###### tags: 'GEOMETRY'
## Question 3 - field chained HTML formatting
We want to create an object with methods for various HTML elements: *div*, *p*, *span* and *h1* for the sake of this question.
These methods will wrap the passed-in string in the tag associated with each.
```javascript=
Format.div("foo"); // returns "<div>foo</div>"
Format.p("bar"); // returns "<p>bar</p>"
Format.span("fiz"); // returns "<span>fiz</span>"
Format.h1("buz"); // returns "<h1>buz</h1>"
```
We also want to be able to add additional formatting by chaining our methods together.
```javascript=
Format.div.h1("FooBar");
// "<div><h1>FooBar</h1><div>"

Format.div.p.span("FizBuz");
// "<div><p><span>FizBuz</span></p></div>"
```
and so on, as deep as we care to use.

Multiple arguments should be concatenated and wrapped in the correct HTML formatting.
```javascript=
Format.div.h1("Foo", "Bar");
// "<div><h1>FooBar</h1></div>"
```
We should be able to store the created methods and reuse them.
```javascript=
var wrapInDiv = Format.div;
wrapInDiv("Foo");   // "<div>Foo</div>"
wrapInDiv.p("Bar"); // "<div><p>Bar</p></div>"

var wrapInDivH1 = Format.div.h1;
wrapInDivH1("Far"); // "<div><h1>Far</h1></div>"
wrapInDivH1.span("Bar"); // "<div><h1><span>Bar</span></h1></div>"
```
And finally, we should be able to nest calls.
```javascript=
Format.div(
  Format.h1("Title"), 
  Format.p(`Paragraph with a ${ Format.span('span') }.`)
)
// returns "<div><h1>Title</h1><p>Paragraph with a <span>span
```
###### tags: `FUNDAMENTAL` `ALGORITHYM`
## Question 4 - Complex CSV Parser
We need valid CSV parser!

A [CSV (Comma-Separated Values)](https://en.wikipedia.org/wiki/Comma-separated_values) file is a file that represents tabular data in a simple, text-only manner. At its simplest, a CSV file contains rows of data separated by newlines, and each field is separated by commas.

This parser needs to not only handle CSVs using commas to delimit fields, but it also needs to handle complex field values (which may be wrapped in quotes, and may span multiple lines), and also different delimiters and quote characters.

#### Examples
A simple CSV would look like this:

`a,b,c`
`d,e,f`

which should parse to:
`[['a', 'b', 'c'], ['d', 'e', 'f']]`

While a more complex one might be:

`one,"two wraps`
`onto ""two"" lines",three`
`4,,6`

that becomes

`[['one', 'two wraps\nonto "two" lines', 'three'], ['4', '', '6']]`
#### Specification:
##### Basics
* The parser should return an array of arrays, one array for each row of the CSV file (not necessarily each line of text!).
* Rows are delimited by the newline character `("\n")`.
* Each row is divided by a separator character, by default the comma (`,`). All characters between separators are part of the value — do **not** trim the field value.
* Fields are assumed to be strings — don't convert them to numbers or other types in this kata.
* Empty fields are valid — don't discard empty values at the beginning, middle or end of a row. These should be included as an empty string.
* Likewise, an empty row is still valid, and effectively contains a single empty field.
* For this kata, expect uneven rows. Just include the actual fields in each row, even if the rows have a different number of fields.
##### Quoted Fields
* The parser should handle quoted fields.
* A quoted field starts and ends with the same character, and every character in between makes up the field value, including separator characters. The default quote character is a double quote (`"`).
* Quoted fields may span multiple lines — don't assume a newline means a new row!
* Quoted fields only start immediately following a separator character, newline, or start of the file. If a quote character occurs anywhere else, it should be treated as a normal field value.
* They should be immediately followed by a separator, newline, or the end of the file.
* If a quote character occurs within a quoted field, it is simply doubled. For example, the value `foo "bar" baz` will be encoded as `"foo ""bar"" baz"`. The parser should identify and unescape these values.
* You should check for unclosed quoted fields, and throw an error, but this is not tested here.
#### Alternate Characters
* The parser should handle alternate characters for the separator and quote.
* You may safely assume that the values provided are a single character, but bonus points for error checking.
###### tags: `ALGORITHMS` `PARSING` `STRING` `UTILITIES`