Skip to content
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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

Review fixes #6

wants to merge 13 commits into from

Conversation

haimre
Copy link

@haimre haimre commented Feb 7, 2022

applied fixes following review

let editMode = false;

function getNewID(){
return Math.floor(Math.random()*1000)
Copy link
Owner

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
Copy link
Owner

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
Copy link
Owner

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}`
Copy link
Owner

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'
Copy link
Owner

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>
Copy link
Owner

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)))
Copy link
Owner

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants