This repository contains solutions for a series of tasks related to JavaScript objects, scopes, and closures. The tasks aim to help you practice creating classes, working with objects, understanding closures, and more.
This project is part of an educational exercise focusing on JavaScript programming concepts. It covers topics such as object creation, class definitions, inheritance, closures, and more. The goal is to provide you with hands-on experience in working with JavaScript's object-oriented features.
To run and test the project, ensure you have Node.js 14.x installed. If you don't have it installed, you can follow these steps to set it up:
-
Install Node.js 14 using NodeSource:
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
-
Install Node.js and npm:
sudo apt-get install -y nodejs
-
Install the
semistandard
coding style:sudo npm install semistandard --global
-
Clone this repository:
git clone https://github.com/mugambi12/alx-higher_level_programming.git
-
Navigate to the project directory:
cd alx-higher_level_programming/0x13-javascript_objects_scopes_closures
To run the code for each task, navigate to the specific task directory and execute the corresponding JavaScript file using Node.js. For example:
cd 0-rectangle
node 0-main.js
Ensure you have execution permission on the JavaScript files:
chmod +x *.js
The project contains a series of tasks, each located in its respective directory. Each task involves creating or working with JavaScript classes, objects, and closures. The repository structure is organized as follows:
- 0-rectangle: Empty class definition for a rectangle.
- 1-rectangle: Rectangle class with constructor to set width and height.
- 2-rectangle: Rectangle class with constructor that validates dimensions.
- 3-rectangle: Rectangle class with a print method to display the rectangle.
- 4-rectangle: Rectangle class with methods to print, rotate, and double.
- 5-square: Square class that inherits from Rectangle.
- 6-square: Square class that inherits from Square and adds a charPrint method.
- 7-occurrences: Function to count occurrences in a list.
- 8-esrever: Function to reverse a list without using the built-in reverse method.
- 9-logme: Function to print the number of arguments and their values.
- 10-converter: Function to convert a number to a different base.
- 100-data: Sample data for advanced task 11.
- 100-map: Script to compute a new array using map and the sample data.
- 101-sorted: Script to compute a dictionary of user ids by occurrence using the sample data.
- 102-concat: Script to concatenate two files and save the result in a destination file.
Each task folder contains its corresponding JavaScript file along with a brief description of the task's requirements and expected output.
This project is licensed under the MIT License - see the LICENSE file for details.