Skip to content
Open
Changes from 1 commit
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
15 changes: 14 additions & 1 deletion src/scripts/main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
'use strict';

const pushNotification = (posTop, posRight, title, description, type) => {
// write code here
const node = document.createElement('div');
const titleNode = document.createElement('h2');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You create the title h2 node but never give it the required title class. Per checklist items #7 and #13 add titleNode.classList.add('title') so the element has the expected class.

const descripNode = document.createElement('p');

node.classList.add(`notification`, type);

node.style.top = posTop;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Assigning node.style.top = posTop will not include units when posTop is a number. Use a string with units (for example node.style.top = posTop + 'px') so positioning works reliably.

node.style.right = posRight;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same for right: set node.style.right = posRight + 'px' (or accept a proper CSS unit string) so the value is valid CSS.


node.append(titleNode);
node.append(descripNode);

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 notification node is never appended to the document, so it will not be visible. Append it (for example document.body.append(node)), ideally after setting its content and classes to satisfy checklist item #3.

titleNode.innerText = title;
descripNode.innerText = description;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You must hide the message visually after 2 seconds instead of removing it from the DOM. Use setTimeout to change a style property (e.g., node.style.display = 'none' or node.style.visibility = 'hidden') after 2000ms to satisfy checklist items #4, #12 and #15.

};

pushNotification(
Expand Down
Loading