javascript - Is my code right, and is the book I am using wrong? Or am I just losing my mind? -
i using john pollocks "a beginners guide javascript edition 3."
the lesson doing 4-2 can found here:http://www.cs.tufts.edu/es/93idi/refs/pollock-3rd.pdf page number pdf 107(actual page number 83/84).
correct me if wrong instructions print "hi there!" screen, while giving alert saying "regular text" after printing "this strong text" screen.
so following instructions js code named prjs4_2.js in external file should be
function two_strings(text1,text2) { var added_text=text1+ " " +text2; return added_text; } function result() { var get_result=two_strings("hi","there!"); document.write(get_result); } var ff_result = two_strings("regular","text"); window.alert(ff_result); result();
then here html code
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body> <p><strong>"this strong text!"</strong></p> <script type="text/javascript" src="prjs4_2.js"></script> </body> </html>
it took me while code, because reading result of should be, , reading text , thinking "this doesn't make sense" realized has backwards changed this.
function two_strings(text1,text2) { var added_text=text1+ " " +text2; return added_text; } function result() { var get_result=two_strings("hi","there!"); window.alert(get_result); } var first_function_result = two_strings("regular","text"); document.write(first_function_result); result();
then came out way describes should.
so question is, book wrong, or did wrong somehow, or did right switching around? think know answer whole question make sure not going mad , book has been published , being used teach people has incorrect information.
you correct. steps 3-6 describe code in first snippet, while description following exercise expresses result of second snippet.
in publishing, errors rather common - , pdf on 500 pages long. unfortunately though, quick google search reveals no errata page, , according an amazon review either well-hidden or nonexistent. there happen fourth edition may or may not have corrected this.
i salute being astute, reading carefully, , questioning when doesn't make sense - it's rather lost art these days. if you're doing part of course, might want mention professor or on class discussion board. otherwise, let's hope next person finds question , answer.
Comments
Post a Comment