This project contains a series of JavaScript exercises organized by topic, along with Jest tests to validate the solutions.
Before you begin, ensure that Node.js is installed on your system. All necessary dependencies, including Jest, are already listed in the project configuration. To install the dependencies, run:
npm install
To view the output of the console.log() statements in any of the exercises, you can directly run the JavaScript file in your terminal using the following command:
node path/to/file.js
Note: The exact path to each file (path/to/file.js) is provided in the corresponding exercise file, making it easy to locate and run the specific exercise you’re working on.
This project uses Jest for testing. The tests are designed to verify that the console.log() statements produce the expected outputs and that variables and values are correctly set according to the exercise instructions.
Note: The exact command (npm run test:X.X.X) is provided in each exercise file, so you can easily locate and run the specific test you need.
To run the Jest test associated with a specific exercise, use the appropriate npm script with the following command:
Declaring Variables:
npm run test:1.1
Specific Tests:
npm run test:1.1.1 Declare a Variable
npm run test:1.1.2 Changing Variable Value
npm run test:1.1.3 Using const
npm run test:1.1.4 Declaring Multiple Variables
npm run test:1.1.5 Dynamic Variable Declaration
Numeric Variables:
npm run test:1.2
Specific Tests:
npm run test:1.2.1 Declare a Numeric Variable
npm run test:1.2.2 Performing Arithmetic Operation
npm run test:1.2.3 Using const for Mathematical Constant
npm run test:1.2.4 Declaring and Multiplying
npm run test:1.2.5 Dynamic Numeric Variable Declaration
Updating Variable Values:
npm run test:1.3
Specific Tests:
npm run test:1.3.1 Incrementing a Variable
npm run test:1.3.2 Decrementing a Variable
npm run test:1.3.3 Doubling the Value
npm run test:1.3.4 Updating With Arithmetic Operation
npm run test:1.3.5 Updating with a Compound Assignment
String Concatenation:
npm run test:1.4
Specific Tests:
npm run test:1.4.1 Combine First and Last Name
npm run test:1.4.2 Concatenate a Greeting
npm run test:1.4.3 Combine Strings with a Number
npm run test:1.4.4 Concatenate Strings with an Expression
npm run test:1.4.5 Concatenate Strings with const and let
Data Types:
npm run test:1.5
Specific Tests:
npm run test:1.5.1 Declare a String Variable
npm run test:1.5.2 Declare a Number Variable
npm run test:1.5.3 Declare a Boolean Variable
npm run test:1.5.4 Declare an Undefined Variable
npm run test:1.5.5 Declare a Null Variable
npm run test:1.5.6 Declare an Object Variable
npm run test:1.5.7 Declare an Array Variable
String Manipulation:
npm run test:1.6
Specific Tests:
npm run test:1.6.1 Concatenate Strings
npm run test:1.6.2 Uppercase and Lowercase
npm run test:1.6.3 Extract Substring
npm run test:1.6.4 Replace Substring
npm run test:1.6.5 String Length
Arithmetic Operators:
npm run test:1.7
Specific Tests:
npm run test:1.7.1 Addition
npm run test:1.7.2 Subtraction
npm run test:1.7.3 Multiplication
npm run test:1.7.4 Division
npm run test:1.7.5 Modulus
Comparison Operators:
npm run test:1.8
Specific Tests:
npm run test:1.8.1 Equal Operator
npm run test:1.8.2 Not Equal Operator
npm run test:1.8.3 Strict Equal Operator
npm run test:1.8.4 Greater Than Operator
npm run test:1.8.5 Less Than Operator
npm run test:1.8.6 Greater Than or Equal To Operator
npm run test:1.8.7 Less Than or Equal To Operator
Logical Operators:
npm run test:1.9
Specific Tests:
npm run test:1.9.1 Logical AND
npm run test:1.9.2 Logical OR
npm run test:1.9.3 Logical NOT
npm run test:1.9.4 Complex Logical Operation
npm run test:1.9.5 Short-Circuit Evaluation
Conditional Statements: npm run test:2.10
Specific Tests:
npm run test:2.10.1 Simple if Statement
npm run test:2.10.2 if-else Statement
npm run test:2.10.3 if-else if-else Statement
npm run test:2.10.4 Switch Statement
npm run test:2.10.5 Nested if Statements
Ternary Operator: npm run test:2.11
Specific Tests:
npm run test:2.11.1 Basic Ternary Operator
npm run test:2.11.2 Ternary Operator with Numbers
npm run test:2.11.3 Nested Ternary Operator
npm run test:2.11.4 Ternary Operator with Strings
npm run test:2.11.5 Ternary Operator with Boolean Expression
Loops: npm run test:2.12
Specific Tests:
npm run test:2.12.1 for Loop
npm run test:2.12.2 while Loop
npm run test:2.12.3 do-while Loop
npm run test:2.12.4 for...in Loop
npm run test:2.12.5 for...of Loop
Loop Control Statements: npm run test:2.13
Specific Tests:
npm run test:2.13.1 break Statement
npm run test:2.13.2 continue Statement
npm run test:2.13.3 Nested Loop with break
npm run test:2.13.4 Nested Loop with continue
Switch Statements: npm run test:2.14
Specific Tests:
npm run test:2.14.1 Basic Switch Statement
npm run test:2.14.2 Switch Statement with Numeric Values
npm run test:2.14.3 Switch Statement with Multiple Cases
npm run test:2.14.4 Switch Statement with Fall-Through
npm run test:2.14.5 Switch Statement with Default Case Only
Declaring Functions: npm run test:3.15
Specific Tests:
npm run test:3.15.1 Function Declaration
npm run test:3.15.2 Function Expression
npm run test:3.15.3 Arrow Function
npm run test:3.15.4 Function with Default Parameter