-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.js
More file actions
63 lines (46 loc) · 1.4 KB
/
Test.js
File metadata and controls
63 lines (46 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
function getDayFromDate(dateString) {
// Parse the date string (format: DD-MM-YYYY)
const [day, month, year] = dateString.split('-').map(num => parseInt(num, 10));
// Create Date object (month is 0-indexed in JavaScript Date)
const date = new Date(year, month - 1, day);
// Get day of week (0 = Sunday, 1 = Monday, ..., 6 = Saturday)
const dayOfWeek = date.getDay();
// Convert to 1 = Monday, ..., 7 = Sunday format
const dayNumber = dayOfWeek === 0 ? 7 : dayOfWeek;
// Array of weekday names
const weekdays = [
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
];
// Return an object with both the name and the number
return dayNumber;
}
// Example usage
// const dateString = "13-05-2025";
// const result = getDayFromDate(dateString);
// console.log(`Date: ${dateString}`);
// console.log(`Day number: ${result}`);
// var a = 'C';
// var result;
// switch (a)
// {
// case 'A':
// result = 'A';
// break;
// case 'B':
// result = 'B';
// break;
// case 'C':
// result += '1'+2;
// break;
// default:
// result = 'Unknown';
// }
// console.log(result); // Output: 8
//prompt("Enter first number: ");
// let num2 = prompt();
// //console.log(num1);
// console.log(num2);
import rl from 'readline-sync';
let n1 = rl.question("Enter first number: ");
let n2 = rl.question("Enter second number: ");
console.log(n1);