Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Week2 Assignment- Codelawer[Abdi] #10

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

codelawer
Copy link

Hello. I cant manage to the app.delete method. Because even if delete in the browser I couldnt manage to delete in the json file.
Can give me advice about delete method.
Merci d'avance.

@codelawer codelawer changed the title Week2 Week2 Assignment- Codelawer[Abdi] Jun 27, 2019
@dfdeagle47
Copy link
Owner

Quick notes

For the DELETE route, you tried using the delete keyword. However, as written, this will delete the variable found (setting its value to undefined in the process), but it will not affect the array. To modify the array in place, you could use the Array.splice method (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice). Alternatively, you could create a new array without the deleted post, and change the value of the posts variable. In that case, you will probably have the change the const posts = ... line to let posts = ... if you want to be able to re-assign a value to posts.

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