Skip to content

Review fixes#6

Open
haimre wants to merge 13 commits into
ofirdagan:mainfrom
haimre:review-fixes
Open

Review fixes#6
haimre wants to merge 13 commits into
ofirdagan:mainfrom
haimre:review-fixes

Conversation

@haimre
Copy link
Copy Markdown

@haimre haimre commented Feb 7, 2022

applied fixes following review

Comment thread 1-Vanilla/index.js
let editMode = false;

function getNewID(){
return Math.floor(Math.random()*1000)
Copy link
Copy Markdown
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)
  );
}

Comment thread 1-Vanilla/index.js
return Math.floor(Math.random()*1000)
}
function addItem(){
let title = document.getElementById('title-input').value
Copy link
Copy Markdown
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

Comment thread 1-Vanilla/index.js
let itemElement = createTodoItemElement(id,title,content)

list.appendChild(itemElement)
// now save to local storage
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

no comments

Comment thread 1-Vanilla/index.js

list.appendChild(itemElement)
// now save to local storage
let itemString = `title: ${title};content: ${content}`
Copy link
Copy Markdown
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

Comment thread 1-Vanilla/index.js

// reset menu display
clearMenu()
document.getElementById('menu-button').innerText = 'add item'
Copy link
Copy Markdown
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?

Comment thread 1-Vanilla/index.html
</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
Copy Markdown
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?

Comment thread 1-Vanilla/index.js
// load display todo items from local storage
let list = document.getElementById('list')
for (let key in localStorage) {
if(isNaN(Number(key)))
Copy link
Copy Markdown
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