For my assignment, I have to read 3 inputs. Once I have the input, I have to pass them as arguments to the addNewPost function. I understand that I have to use the .apply function, however, I am confused on how to do this even after looking at various sources online.
function handleFormSubmit() {
var username = document.getElementById("input-username").value,
password = document.getElementById("input-password").value,
picture = document.getElementById("input-picture").value;
addNewPost.apply(this, arguments);
}
function addNewPost(username, img_src, caption) {
}
If using apply
is not a requirement, you can simply pass them into the function;
addNewPost(username, password, picture);