-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Review fixes #6
base: main
Are you sure you want to change the base?
Review fixes #6
Conversation
… alerts, accessive indentaions removed
let editMode = false; | ||
|
||
function getNewID(){ | ||
return Math.floor(Math.random()*1000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not good enough. the probability of getting the same id is 1/1000 which is pretty high. why didn't u take the guid generation function?
function uuidv4() {
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
);
}
return Math.floor(Math.random()*1000) | ||
} | ||
function addItem(){ | ||
let title = document.getElementById('title-input').value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the default should be always const
unless your'e going to change either the pointer or if it's a primitive its value.
change all let
to const
unless u have to use let
let itemElement = createTodoItemElement(id,title,content) | ||
|
||
list.appendChild(itemElement) | ||
// now save to local storage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no comments
|
||
list.appendChild(itemElement) | ||
// now save to local storage | ||
let itemString = `title: ${title};content: ${content}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line 24+25 should be in its own function
|
||
// reset menu display | ||
clearMenu() | ||
document.getElementById('menu-button').innerText = 'add item' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where's the shortcut for document.getElementById(X).value
?
</div> | ||
<div class='menu-buttons'> | ||
<button id='clear-button' class='clear-button'>clear</button> | ||
<button id='menu-button' class='menu-button'>add item</button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why add
is called menu-button
?
// load display todo items from local storage | ||
let list = document.getElementById('list') | ||
for (let key in localStorage) { | ||
if(isNaN(Number(key))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's that? what failed so u had to add this condition?
applied fixes following review