add input in custom javascript from WordPress pages/posts

What you need its either a custom field or a meta box, you can search there are plenty of tutorials for creating both being the custom field the simpler one, you can read about it here, first you have to see the custom fields, for that you need to open the screen options and check the custom field checkbox, this in your page/post edit screen:

enter image description here

then you can start creating your custom fields, they can be added for posts and pages, in here you can see i created one called 'hint':

enter image description here

then you can use retrieve it, like this (inside the loop):

<?php
// Start the loop.
while (have_posts()) : the_post();
    the_content();

    //here we retrieve the value and save it in a var to use it later
    $hint_of_this_page = get_post_meta( get_the_ID(), 'hint', true );


 // End the loop.
 endwhile;
 ?>

then use it like this in your front-end code (in the footer i guess):

<?php global $hint_of_this_page; ?>
function answerbutton() {
    document.getElementById("answer").innerHTML = '<?php echo $hint_of_this_page; ?>';
}

it will show like this:

enter image description here