I have an input area in my HTML.
<input id="bookTitle" type="text">
Now, my javascript look like this:
function Book(title){
this.title = title;
}
function addToLibrary(){
const title = document.querySelector("#bookTitle").value;
const book = new Book(title) // replace the book variable name with the value of title
}
How do I make it so that the instead of the instantiating Book Class with variable book, I instantiate it with the value of title itself.
For Example,
If my input has value "Hobbit", I want Hobbit to be the variable name instead of book.