I do not use P5.js often but able to use it with P5.js mode in the Processing PDE (you need to update the *.js files to current ones) and as per instructions here.
You can expect to have students visit the forums and there is a homework policy here.
I’ve seen feature requests for a private option, I am sure it will come. Until then, like @GoToLoop suggested, throw the solution up on a private gist or repo, maybe even in dropbox and only allow those with the link to view it.
Another option is to host the solution on the web editor and then delete it at the end of the semester.
Thank you for your reply. Switching to using processing IDE instead of p5js to conduct my classes. This way all my sketches can be offline. Plus i can teach coding in java and students learn how to use a modern IDE at the same time. I chose processing to introduce first time students to coding as the ouput is more tangible and less abstract. This pipes up the interest of the students especially children