Prototypes for functions written in this project:
File | Prototype |
---|---|
7-occurrences.js |
exports.nbOccurences = function (list, searchElement) |
8-esrever.js |
exports.esrever = function (list) |
9-logme.js |
exports.logMe = function (item) |
10-converter.js |
exports.converter = function (base) |
-
0. Rectangle #0
- 0-rectangle.js: JavaScript script that defines an empty
class
Rectangle
.
- 0-rectangle.js: JavaScript script that defines an empty
class
-
1. Rectangle #1
- 1-rectangle.js: JavaScript script that defines a class
Rectangle
. Builds on 0-rectangle.js with:- Constructor that initializes instance attributes
width
andheight
with given parametersw
andh
.
- Constructor that initializes instance attributes
- 1-rectangle.js: JavaScript script that defines a class
-
2. Rectangle #2
- 2-rectangle.js: JavaScript script that defines a class
Rectangle
. Builds on 1-rectangle.js with:- If provided
w
andh
are less than or equal to0
, creates an empty object.
- If provided
- 2-rectangle.js: JavaScript script that defines a class
-
3. Rectangle #3
- 3-rectangle.js: JavaScript script that defines a class
Rectangle
. Builds on 3-rectangle.js with:- Instance method
print()
that prints the rectangle using theX
character.
- Instance method
- 3-rectangle.js: JavaScript script that defines a class
-
4. Rectangle #4
- 4-rectangle.js: JavaScript script that defines a class
Rectangle
. Builds on 4-rectangle.js with:- Instance method
rotate()
that swaps thewidth
andheight
of theRectangle
. - Instance method
double()
that multiplies thewidth
andheight
of theRectangle
by2
.
- Instance method
- 4-rectangle.js: JavaScript script that defines a class
-
5. Square #0
- 5-square.js: JavaScript script that defines a class
Square
that inherits fromRectangle
.- Constructor takes one argument
size
.
- Constructor takes one argument
- 5-square.js: JavaScript script that defines a class
-
6. Square #1
- 6-square.js: JavaScript script that defines a class
Square
that inherits fromRectangle
. Builds on 5-square.js with:- Instance method
charPrint(c)
that prints theSquare
using the characterc
. - If
c
isundefined
, uses the characterX
.
- Instance method
- 6-square.js: JavaScript script that defines a class
-
7. Occurrences
- 7-occurrences.js: JavaScript function that returns the number of occurrences in a list.
-
8. Esrever
- 8-esrever.js: JavaScript function that reverses a list.
-
9. Log me
- 9-logme.js: JavaScript function that prints the number of arguments already printed as well as the new argument value.
- Output:
<number arguments already printed>: <current argument value>
-
10. Number conversion
- 10-converter.js: JavaScript function that converts a number from base 10 to another base passed as argument.
-
11. Factor index
- 100-map.js: JavaScript script that imports an array and creates a new array with each value equal to the value of initial list times the index of the new list.
- Prints both the initial and new list.
-
12. Sorted occurences
- 101-sorted.js: JavaScript script that imports a dictionary of occurrences by user ID and computes a new dictionary of user ID's by occurrences.
- Prints the new dictionary.
-
13. Concat files
- 102-concat.js: JavaScript script that concatenates two files passed as arguments into a file specifed as the third argument.
- Usage:
./102-concat.js fileA fileB fileC
.