-
Notifications
You must be signed in to change notification settings - Fork 70
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
Solution by Volha Afanasenka & Juan Carlos Cabello #48
base: main
Are you sure you want to change the base?
Solution by Volha Afanasenka & Juan Carlos Cabello #48
Conversation
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.
Good job
return (a.id.toString() - b.id.toString()); | ||
}) | ||
data.forEach(post =>{ | ||
const postElement = document.createElement("section"); |
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.
Perhaps having a template would be better then creating each element
@@ -0,0 +1,100 @@ | |||
import {modifyingPost} from "./modifyPost.js"; | |||
import { deletingPost } from "./deletePost.js"; |
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.
Only one function per javaScript? Is this optimal? Or could you have gathered more functions under one js, i.e postFunctions.js userFunctions.js commentFunctions.js . Calling many files may not be a great thing.
@@ -0,0 +1,19 @@ | |||
import { getPosts } from "./main.js"; | |||
export function modifyingPost(id, user){ | |||
const modalModify = document.getElementById("staticBackdrop-form"); |
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.
const modalModify = document.getElementById("staticBackdrop-form");
const modalModifyButton = document.getElementById("modifyPostButton");
If variables are not used they should be removed, so that your code is easier to read
}) | ||
postsList.append(postElement); | ||
}) | ||
}else{//if the user deleted some posts or modify some post, we delete all li and create all of them from the beggining |
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.
it should be the other way, when you delete something you refresh the posts
const postTitle = post.title; | ||
postElement.append(postTitle); | ||
postElement.setAttribute("id", post.id); | ||
postElement.setAttribute("userId", post.userId); |
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.
.then(response=>response.json()) | ||
.then(data=>{ | ||
const postsList = document.getElementById("listGroup"); | ||
Array.from(document.getElementById("listGroup").children).forEach(son=>{ |
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.
We assume you guys creating an array because you want to iterate over a html collection?
it can be done with a for loop, or for in loop.
Guys, thanks for the review, your comments are very useful. |
Solution by Volha Afanasenka & Juan Carlos Cabello