Проблем със задача 01. Mails Delivery от JS Advanced Exam - 13 March 2022
Здравейте, имам проблем, https://pastebin.com/TsQRdhd9 в браузъра изглежда, че работи, но в джъдж получавам 45/100. Някой може ли да ми помогне, къде е проблемът.
Здравейте, имам проблем, https://pastebin.com/TsQRdhd9 в браузъра изглежда, че работи, но в джъдж получавам 45/100. Някой може ли да ми помогне, къде е проблемът.
100% code =>
;-)
function solve() {
let recipientName = document.getElementById("recipientName");
let title = document.getElementById("title");
let message = document.getElementById("message");
let btnAdd = document.getElementById("add");
let list = document.getElementById("list");
let btnReset = document.getElementById("reset");
let sentList = document.getElementsByClassName("sent-list")[0];
let deleteList = document.getElementsByClassName("delete-list")[0];
btnReset.addEventListener("click", (ev) => {
ev.preventDefault();
resetting();
});
btnAdd.addEventListener("click", (ev) => {
ev.preventDefault();
adding();
recipientName.value = "";
title.value = "";
message.value = "";
});
function resetting() {
recipientName.value = "";
title.value = "";
message.value = "";
}
function adding() {
let recipientNameValue = recipientName.value;
let titleValue = title.value;
let messageValue = message.value;
if (recipientNameValue && titleValue && messageValue) {
let li = document.createElement("li");
let h4 = document.createElement("h4");
h4.textContent = `Title: ${titleValue}`;
let h42 = document.createElement("h4");
h42.textContent = `Recipient Name: ${recipientNameValue}`;
let span = document.createElement("span");
span.textContent = `${messageValue}`;
let div = document.createElement("div");
div.setAttribute("id", "list-action");
let buttonsend = document.createElement("button");
buttonsend.setAttribute("type", "submit");
buttonsend.setAttribute("id", "send");
buttonsend.textContent = "Send";
buttonsend.addEventListener("click", (event) => {
event.preventDefault();
sending(event);
});
let buttondelete = document.createElement("button");
buttondelete.setAttribute("type", "submit");
buttondelete.setAttribute("id", "delete");
buttondelete.textContent = "Delete";
buttondelete.addEventListener("click", (ev) => {
ev.preventDefault();
deletting(ev);
});
div.appendChild(buttonsend);
div.appendChild(buttondelete);
li.appendChild(h4);
li.appendChild(h42);
li.appendChild(span);
li.appendChild(div);
list.appendChild(li);
}
}
function sending(event) {
let listTitle = event.target.parentElement.parentElement.children[0];
let listRecipientName = event.target.parentElement.parentElement.children[1];
let butdelete = event.target.parentElement.parentElement.children[3].children[1];
let newDelete = butdelete;
newDelete.removeAttribute('id');
newDelete.setAttribute('class', 'delete');
let li = document.createElement("li");
let span = document.createElement("span");
span.textContent = `To: ${listRecipientName.textContent.split(": ")[1]}`;
let span2 = document.createElement("span");
span2.textContent = listTitle.textContent;
let div = document.createElement("div");
div.setAttribute("class", "btn");
div.appendChild(newDelete);
li.appendChild(span);
li.appendChild(span2);
li.appendChild(div);
sentList.appendChild(li);
event.target.parentElement.parentElement.remove();
}
function deletting(event) {
let listTitle = event.target.parentElement.parentElement.children[0];
let listRecipientName = event.target.parentElement.parentElement.children[1];
let li = document.createElement("li");
let spanTitle = document.createElement("span");
let spanRecipName = document.createElement("span");
if (listRecipientName.textContent.includes('Recipient Name')) {
spanTitle.textContent = 'To: ' + listRecipientName.textContent.split(': ')[1];
spanRecipName.textContent = 'Title: ' + listTitle.textContent.split(': ')[1];
} else {
spanTitle.textContent = listTitle.textContent;
spanRecipName.textContent = listRecipientName.textContent;
}
li.appendChild(spanTitle);
li.appendChild(spanRecipName);
deleteList.appendChild(li);
event.target.parentElement.parentElement.remove();
}
}