How do I test my code for Gamebook


#1


So I am starting my java final Gamebook, and I was wondering what is the best way to test my code as I go to ensure everything is working properly?


Replace this line with your code.


#2

In this project, you’ll build a game from scratch. You’ll leave Codecademy’s learning environment and build locally, on your own computer, testing and running the game in the browser.

You'll want to run and test with the console open so error messages are visible. Is the code performing as expected? What methodology have you established to rigorously test the edge cases? Have you devised ways to break your code, and then make it stronger?


#3

So what I initially tried was opening my main html file directly in the browser to try playing the game. Is that the correct method? I was trying to create a thread for my game just like the one we created in the Threadly exercise, so i cut and pasted the code from that exercise into my code and it still didn't work in the browser. However, it works perfectly in the code academy site, and in a java code test site... why is that?

here is the java code:

var main = function() {
$('form').submit(function() {
var comment = $('#comment').val();

if(comment !== "") {
  var html = $('<li>').text(comment);
  $(html).prependTo('.comments');
  $('#comment').val("");
}

return false;

});
};

$(document).ready(main);

here is the HTML...

<!doctype html>
<html>
  <head>
    <link href='https://fonts.googleapis.com/css?family=Montserrat:400,700' rel='stylesheet' type='text/css'>
  <link rel='stylesheet' href='style.css'/>
  </head>
  <body>

    <div class="header">
      <div class="container">
        <h1>threadly</h1>
      </div>
    </div>

    <div class="main">
      <div class="container">
        
        <form class="form">
          <input id="comment" type="text" placeholder="share your thoughts">
          <button type="submit" class="btn">post</button>
        </form>

        <ul class="comments">
          <li>Have you felt it?</li>
          <li>There has been an awakening.</li>
        </ul>
      </div>
    </div>

    <script src="https://s3.amazonaws.com/codecademy-content/projects/jquery.min.js"></script>
    <script src='script.js'></script>
  </body>
</html>

#4

Yes, that's the best way to test. See how it looks and feels. Is the behavior what is expected?

This site has jQuery loaded in the background, for one.

Add this script tag before your own js...

<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>

Actually, I didn't scroll down far enough to see that you already have it coming from CC. I recommend you use the above CDN, rather than CC's Amazon account.


#5

I hate life right now... That was such a stupid mistake. I deleted a bunch of old code because I thought I had made a mistake and the whole time it was just the missing jQuery script tag... Thank you very much mtf I appreciate your help.