├── 6.js
├── 5.js
├── 3.js
├── 4.js
├── 1.js
├── js codes
├── 3.html
├── 6.html
├── 7.html
├── 5.html
├── 2.html
├── 1.html
└── 4.html
├── .vscode
└── launch.json
├── 7.js
├── 2.js
├── activity1
├── 1.html
├── convertingstrings.html
├── 2.html
└── convertingnum.html
├── html code -2
└── Untitled-1.html
├── html code
├── Untitled-1.html
└── styles.css
├── Javascript code-1
└── Untitled-1.html
├── html code -3
├── styles.css
└── Untitled-1.html
├── LICENSE
├── 8-1.js
├── 8-2.js
└── 8-3.html
/6.js:
--------------------------------------------------------------------------------
1 | function squareNumber(num) {
2 | return num * num;
3 | }
4 |
5 |
6 | console.log(squareNumber(4));
7 |
--------------------------------------------------------------------------------
/5.js:
--------------------------------------------------------------------------------
1 | function printOddNumbers() {
2 | for (let i = 1; i <= 30; i += 2) {
3 | console.log(i);
4 | }
5 | }
6 |
7 |
8 | printOddNumbers();
9 |
10 | //visit
11 |
--------------------------------------------------------------------------------
/3.js:
--------------------------------------------------------------------------------
1 | function findLargestNumber(num1, num2, num3) {
2 | if (num1 >= num2 && num1 >= num3) {
3 | return num1;
4 | } else if (num2 >= num1 && num2 >= num3) {
5 | return num2;
6 | } else {
7 | return num3;
8 | }
9 | }
10 |
11 |
12 | console.log(findLargestNumber(7, 10, 7));
13 |
--------------------------------------------------------------------------------
/4.js:
--------------------------------------------------------------------------------
1 | function isPrime(number) {
2 | if (number <= 1) return false;
3 | if (number <= 3) return true;
4 | if (number % 2 === 0 || number % 3 === 0) return false;
5 |
6 | for (let i = 5; i * i <= number; i += 6) {
7 | if (number % i === 0 || number % (i + 2) === 0) return false;
8 | }
9 |
10 | return true;
11 | }
12 |
13 |
14 | console.log(isPrime(7));
15 | console.log(isPrime(10));
16 |
17 | //visit
18 |
--------------------------------------------------------------------------------
/1.js:
--------------------------------------------------------------------------------
1 | function getGreeting(time) {
2 |
3 | const [hours, minutes] = time.split(':').map(Number);
4 |
5 | if (hours < 10) {
6 | return "Good morning";
7 | } else if (hours < 20) {
8 | return "Good day";
9 | } else {
10 | return "Good evening";
11 | }
12 | }
13 |
14 |
15 | console.log(getGreeting("09:30"));
16 | console.log(getGreeting("14:45"));
17 | console.log(getGreeting("21:00"));
18 | console.log(getGreeting("20:00"));
19 |
20 |
--------------------------------------------------------------------------------
/js codes/3.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Area of Rectangle
7 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/js codes/6.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Concatenate Statements
7 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/js codes/7.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Output for Variables
7 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "chrome",
9 | "request": "launch",
10 | "name": "Launch Chrome against localhost",
11 | "url": "http://localhost:8080",
12 | "webRoot": "${workspaceFolder}"
13 | }
14 | ]
15 | }
--------------------------------------------------------------------------------
/7.js:
--------------------------------------------------------------------------------
1 | function reverseNumber(num) {
2 |
3 | let numStr = num.toString();
4 |
5 | // Split the string into an array of characters, reverse the array, and join it back into a string
6 | let reversedStr = numStr.split('').reverse().join('');
7 |
8 | // Convert the reversed string back into a number
9 | let reversedNum = parseInt(reversedStr);
10 |
11 | return reversedNum;
12 | }
13 |
14 |
15 | let sampleInput = 32243;
16 | let sampleOutput = reverseNumber(sampleInput);
17 | console.log(sampleOutput); //print in terminal
18 |
--------------------------------------------------------------------------------
/2.js:
--------------------------------------------------------------------------------
1 |
2 | function getFruitColor(fruit) {
3 | switch (fruit) {
4 | case 'banana':
5 | console.log("Yellow");
6 | break;
7 | case 'pineapple':
8 | console.log("Orange");
9 | break;
10 | case 'apple':
11 | console.log("Green");
12 | break;
13 | default:
14 | console.log("Unknown fruit");
15 | break;
16 | }
17 | }
18 |
19 |
20 | getFruitColor('banana');
21 | getFruitColor('pineapple');
22 | getFruitColor('apple');
23 |
24 | //visit
25 |
--------------------------------------------------------------------------------
/js codes/5.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Comparison Operations
7 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/js codes/2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Display Personal Info
7 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/activity1/1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | JavaScript String Operations
7 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/js codes/1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Marks Calculation
7 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/html code -2/Untitled-1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Simple Form
7 |
8 |
9 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/html code/Untitled-1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Insert Name and Hometown
7 |
8 |
9 |
10 |
11 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/Javascript code-1/Untitled-1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | JavaScript Exercise 01
7 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/html code -3/styles.css:
--------------------------------------------------------------------------------
1 | body {
2 | font-family: Arial, sans-serif;
3 | background-color: #f9f9f9;
4 | display: flex;
5 | justify-content: center;
6 | align-items: center;
7 | height: 100vh;
8 | margin: 0;
9 | }
10 |
11 | .form-container {
12 | background: #fff;
13 | padding: 20px;
14 | border-radius: 5px;
15 | box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
16 | width: 250px;
17 | text-align: left;
18 | }
19 |
20 | h2 {
21 | font-size: 1.25em;
22 | margin: 0 0 15px;
23 | }
24 |
25 | label.package {
26 | display: block;
27 | margin: 10px 0;
28 | }
29 |
30 | input[type="checkbox"] {
31 | margin-right: 10px;
32 | }
33 |
34 | button {
35 | width: 100%;
36 | padding: 10px;
37 | background: #6c757d;
38 | color: #fff;
39 | border: none;
40 | border-radius: 4px;
41 | cursor: pointer;
42 | margin-top: 15px;
43 | }
44 |
45 | button:hover {
46 | background: #5a6268;
47 | }
48 |
--------------------------------------------------------------------------------
/html code/styles.css:
--------------------------------------------------------------------------------
1 | body {
2 | font-family: Arial, sans-serif;
3 | background-color: #f4f4f4;
4 | display: flex;
5 | justify-content: center;
6 | align-items: center;
7 | height: 100vh;
8 | margin: 0;
9 | }
10 |
11 | .form-container {
12 | background: #fff;
13 | padding: 20px;
14 | border-radius: 5px;
15 | box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
16 | width: 300px;
17 | }
18 |
19 | h2 {
20 | margin-top: 0;
21 | }
22 |
23 | label {
24 | display: block;
25 | margin: 15px 0 5px;
26 | }
27 |
28 | input[type="text"] {
29 | width: 100%;
30 | padding: 8px;
31 | margin-bottom: 10px;
32 | border: 1px solid #ccc;
33 | border-radius: 4px;
34 | }
35 |
36 | button {
37 | width: 100%;
38 | padding: 10px;
39 | background: #5cb85c;
40 | color: #fff;
41 | border: none;
42 | border-radius: 4px;
43 | cursor: pointer;
44 | }
45 |
46 | button:hover {
47 | background: #4cae4c;
48 | }
49 |
--------------------------------------------------------------------------------
/js codes/4.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Operations on Variables
7 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/html code -3/Untitled-1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Hotel Packages Form
7 |
8 |
9 |
10 |
11 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 Hirun
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/activity1/convertingstrings.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | JavaScript Type Conversions
7 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/activity1/2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | JavaScript String Operations
7 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/activity1/convertingnum.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | JavaScript Type Conversions
7 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/8-1.js:
--------------------------------------------------------------------------------
1 | class Library {
2 | constructor() {
3 | this.books = [];
4 | }
5 |
6 |
7 | addBook(title, author) {
8 | const newBook = {
9 | title: title,
10 | author: author,
11 | borrowed: false
12 | };
13 | this.books.push(newBook);
14 | }
15 |
16 |
17 | findBook(title) {
18 | for (let i = 0; i < this.books.length; i++) {
19 | if (this.books[i].title === title) {
20 | return i;
21 | }
22 | }
23 | return -1;
24 | }
25 |
26 |
27 | borrowBook(title) {
28 | const bookIndex = this.findBook(title);//findbook
29 | if (bookIndex !== -1 && !this.books[bookIndex].borrowed) {
30 | this.books[bookIndex].borrowed = true;
31 | return `${title} has been borrowed.`; //backticks
32 | } else if (bookIndex !== -1 && this.books[bookIndex].borrowed) {
33 | return `${title} is already borrowed.`;
34 | } else {
35 | return `${title} is not available in the library.`;
36 | }
37 | }
38 |
39 |
40 | returnBook(title) {
41 | const bookIndex = this.findBook(title);
42 | if (bookIndex !== -1 && this.books[bookIndex].borrowed) {
43 | this.books[bookIndex].borrowed = false;
44 | return `${title} has been returned.`;
45 | } else if (bookIndex !== -1 && !this.books[bookIndex].borrowed) {
46 | return `${title} was not borrowed.`;
47 | } else {
48 | return `${title} is not available in the library.`;
49 | }
50 | }
51 | }
52 |
53 |
54 | const myLibrary = new Library();
55 | myLibrary.addBook("The Great Gatsby", "F. Scott Fitzgerald");
56 | myLibrary.addBook("To Kill a Mockingbird", "Harper Lee");
57 |
58 | console.log(myLibrary.borrowBook("The Great Gatsby"));
59 | console.log(myLibrary.borrowBook("The Great Gatsby"));
60 | console.log(myLibrary.returnBook("The Great Gatsby"));
61 | console.log(myLibrary.returnBook("The Great Gatsby"));
62 | console.log(myLibrary.borrowBook("Moby Dick"));
63 |
--------------------------------------------------------------------------------
/8-2.js:
--------------------------------------------------------------------------------
1 | class Library {
2 | #books = []; // Private array for books*
3 |
4 | // Method to add a new book
5 | addBook(title, author) {
6 | const newBook = {
7 | title: title,
8 | author: author,
9 | borrowed: false
10 | };
11 | this.#books.push(newBook);
12 | }
13 |
14 | // Method to find a book by title
15 | findBook(title) {
16 | for (let i = 0; i < this.#books.length; i++) {
17 | if (this.#books[i].title === title) {
18 | return i;
19 | }
20 | }
21 | return -1;
22 | }
23 |
24 | // Method to borrow a book by title
25 | borrowBook(title) {
26 | const bookIndex = this.findBook(title);
27 | if (bookIndex !== -1 && !this.#books[bookIndex].borrowed) {
28 | this.#books[bookIndex].borrowed = true;
29 | return `${title} has been borrowed.`;
30 | } else if (bookIndex !== -1 && this.#books[bookIndex].borrowed) {
31 | return `${title} is already borrowed.`;
32 | } else {
33 | return `${title} is not available in the library.`;
34 | }
35 | }
36 |
37 | // Method to return a borrowed book by title
38 | returnBook(title) {
39 | const bookIndex = this.findBook(title);
40 | if (bookIndex !== -1 && this.#books[bookIndex].borrowed) {
41 | this.#books[bookIndex].borrowed = false;
42 | return `${title} has been returned.`;
43 | } else if (bookIndex !== -1 && !this.#books[bookIndex].borrowed) {
44 | return `${title} was not borrowed.`;
45 | } else {
46 | return `${title} is not available in the library.`;
47 | }
48 | }
49 | }
50 |
51 |
52 | const myLibrary = new Library();
53 | myLibrary.addBook("The Great Gatsby", "F. Scott Fitzgerald");
54 | myLibrary.addBook("To Kill a Mockingbird", "Harper Lee");
55 |
56 | console.log(myLibrary.borrowBook("The Great Gatsby")); // Outputs: The Great Gatsby has been borrowed.
57 | console.log(myLibrary.borrowBook("The Great Gatsby")); // Outputs: The Great Gatsby is already borrowed.
58 | console.log(myLibrary.returnBook("The Great Gatsby")); // Outputs: The Great Gatsby has been returned.
59 | console.log(myLibrary.returnBook("The Great Gatsby")); // Outputs: The Great Gatsby was not borrowed.
60 | console.log(myLibrary.borrowBook("Moby Dick")); // Outputs: Moby Dick is not available in the library.
61 |
--------------------------------------------------------------------------------
/8-3.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Library Management System
7 |
21 |
22 |
23 |
42 |
43 |
111 |
112 |
113 |
--------------------------------------------------------------------------------