JavaScript: programm mit einem joke

hanspeter53

Neues Mitglied
hallo ihr lieben, ich wende mich an euch, da ich leider keine hilfe bei google gefunden habe und hoffe ihr könnt mir ein wenig unterstützend zur seite stehen.

ich muss für eine hausarbeit ein java programm mit einem klopf klopf joke schreiben, werde jedoch aus meinen büchern alles andere als schlau. ich habe noch nie etwas mit java gemacht und bin auch kein computerprofi 🙁

der code sieht wie folgt aus:

<HTML>
<HEAD>
<TITLE>TMA 02 Q4(ii)</TITLE>
<SCRIPT LANGUAGE = "JAVASCRIPT">

var name;
// Declare other variable here

name = window.prompt('Please enter a name to use in the joke', '');
// Prompt for other value here

// Output the customised joke here

</SCRIPT>

</HEAD>
<BODY>
</BODY>
</HTML>



die aufgabenstellung sieht wie folgt aus:

The extract given in Figure 7 is an incomplete version of a JavaScript program that will output a ‘knock knock’ joke. It will prompt the user twice:
once for a name to appear as the response to ‘Who’s there?’;
once for the string to go after the name to complete the punch line.

For example, if the user entered
Isabel
in response to the first prompt, and
not working? I had to knock!
in response to the second prompt, the program would display on the screen:

Knock knock! Who's there? Isabel Isabel who? Isabel not working? I had to knock!


wird daraus irgendjemand schlau? schon einmal 1000 dank 🙂
 
Zuletzt bearbeitet von einem Moderator:
ich habe es jetzt so versucht aber das funktioniert leider nicht..

<HTML>
<HEAD>
<TITLE>TMA 02 Q4(ii)</TITLE>
<SCRIPT LANGUAGE = "JAVASCRIPT">

var name;
var joke;

name = window.prompt('Please enter a name to use in the joke', '');
joke = window.prompt('Whos there?', '');
document.write('Knock knock! Whos there? '+ name + 'who? '+ name +' 'joke +' I had to knock!);

</SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>
 
Wenn mich meine seehr rudmentären JavaScript Kenntnisse nicht im Stich lassen:

Code:
<HTML>
<HEAD>
<TITLE>TMA 02 Q4(ii)</TITLE>
<SCRIPT LANGUAGE = "JAVASCRIPT">

function Go () {


var name;
var joke;

name = window.prompt('Please enter a name to use in the joke', '');
joke = window.prompt('Whos there?', '');
document.write('Knock knock! Whos there? '+ name + ' ' + name +  ' who? '+ name + ' ' + joke);

}

</SCRIPT>
</HEAD>
<BODY onload="Go()">
</BODY>
</HTML>
 

Neue Themen


Zurück
Oben