Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,5 @@ dist
vite.config.js.timestamp-*
vite.config.ts.timestamp-*

node_modules
.env
70 changes: 69 additions & 1 deletion task-1/Time.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,71 @@
export class Time {
// Your code here
}
#secondsFromMidnight;

constructor(hours, minutes, seconds){
const totalSeconds = hours* 3600 + minutes * 60 + seconds;

if (totalSeconds < 0 || totalSeconds >= 86400 ){
throw new Error("Invalid");
}
this.#secondsFromMidnight = totalSeconds;
}


getHours(){
return Math.floor(this.#secondsFromMidnight / 3600);
}

getMinutes(){
return Math.floor((this.#secondsFromMidnight % 3600) / 60);
}

getSeconds(){
return this.#secondsFromMidnight % 60;
}

addSeconds(seconds) {
this.#secondsFromMidnight = (this.#secondsFromMidnight + seconds) % 86400;

if (this.#secondsFromMidnight < 0) {
this.#secondsFromMidnight += 86400;
}
}

addMinutes(minutes){
this.addSeconds(minutes * 60);
}

addHours(hours){
this.addSeconds(hours * 3600);
}

toString() {
const h = String(this.getHours()).padStart(2, "0");
const m = String(this.getMinutes()).padStart(2, "0");
const s = String(this.getSeconds()).padStart(2, "0");

return `${h}:${m}:${s}`;
}

}
const myTime = new Time(12, 35, 0);
console.log(myTime.toString()); // 12:35:00
myTime.getHours(); // 12
myTime.getMinutes(); // 35
myTime.getSeconds(); // 0

myTime.addMinutes(35);
console.log(myTime.toString()); // 13:00:00

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is misleading; it should be 13:10:00


myTime.addHours(12);
console.log(myTime.toString()); // 01:00:00

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is misleading; it should be 01:10:00



const t = new Time(23, 59, 50);
t.addSeconds(15);
console.log(t.toString()); // 00:00:05

const t2 = new Time(0, 0, 5);
t2.addSeconds(-10);
console.log(t2.toString()); // 23:59:55
32 changes: 2 additions & 30 deletions task-1/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

87 changes: 87 additions & 0 deletions task-2/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,88 @@
// Write your code here. You may create as many files as you like.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No LLM API call

import readlineSync from "readline-sync";
import chalk from "chalk";

//using fake JSON for testing
const questions = [
{
question: "What country is Zara from?",
options: ["France", "Spain", "Italy", "Germany"],
correctAnswer: 2,
},
{
question: "Chanel is from?",
options: ["Italy", "France", "USA", "Spain"],
correctAnswer: 2,
},
{
question: "Bershka originates from?",
options: ["Spain", "Germany", "France", "UK"],
correctAnswer: 1,
},
{
question: "Volkswagen is from?",
options: ["Germany", "Italy", "Japan", "USA"],
correctAnswer: 1,
},
{
question: "Nike is from?",
options: ["USA", "UK", "Germany", "France"],
correctAnswer: 1,
},
{
question: "Adidas is from?",
options: ["Germany", "USA", "France", "Italy"],
correctAnswer: 1,
},
{
question: "Gucci is from?",
options: ["Italy", "France", "Spain", "UK"],
correctAnswer: 1,
},
{
question: "H&M is from?",
options: ["Sweden", "Norway", "Germany", "Denmark"],
correctAnswer: 1,
},
{
question: "Puma is from?",
options: ["Germany", "USA", "Italy", "France"],
correctAnswer: 1,
},
{
question: "Louis Vuitton is from?",
options: ["France", "Italy", "Spain", "UK"],
correctAnswer: 1,
},
];


let score = 0;

console.log(chalk.blue("🎮 Welcome to the Brand Quiz Game!\n"));

for (let i = 0; i < questions.length; i++) {
const q = questions[i];

console.log(chalk.yellow(`Question ${i + 1}: ${q.question}`));

for (let j = 0; j < q.options.length; j++) {
console.log(`${j + 1}. ${q.options[j]}`);
}

const answer = readlineSync.question("Your answer (1-4): ");

if (parseInt(answer) === q.correctAnswer) {
console.log(chalk.green("✅ Correct! +1 point\n"));
score++;
} else {
console.log(
chalk.red(
`❌ Wrong! Correct answer: ${q.options[q.correctAnswer - 1]}\n`
)
);
}
}

console.log(chalk.blue(`🎯 Your final score: ${score}/10`));
73 changes: 73 additions & 0 deletions task-2/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions task-2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,11 @@
"keywords": [],
"author": "",
"license": "ISC",
"type": "module"
}
"type": "module",
"dependencies": {
"chalk": "^5.6.2",
"dotenv": "^17.3.1",
"openai": "^6.32.0",
"readline-sync": "^1.4.10"
}
}