JAVASCRIPT HELP. I AM USING NOTEPAD ++ You will download the webpage World Of Zu
ID: 3579636 • Letter: J
Question
JAVASCRIPT HELP. I AM USING NOTEPAD ++
You will download the webpage World Of Zurb and make changes. You will create a simple ability score generator that will allow a person to choose which Character Class they want be and then display their ability scores. The program will allow the user to re-roll the scores if they like.
Document your JavaScript using block comments and line comments.
Use a loop to repeat the program until your user chooses to quit.
Generate six ability scores (Strength, Dexterity, Constition, Wisdom, Intelligence and Charaisma) with heroic values: 3D6 and add 6.
Heroic:
Display the outcome in the text fields.
Ask the user if she/he wants to play roll again and start over if their answer is yes.
Explanation / Answer
/*
HTML code contains text fields with respective id attribute
<input type=text id="strength">
for heroic values of all six abilities
*/
function ability_score () { // function to generate ability score and print in the text fields
var char_class = document.getElementById('class').value();
if(char_class == "digit") { // if user selects digit character class
document.getElementById('strength').innerHTML= (Math.random() * (6 - 1) + 1)+6;
document.getElementById('dexterity').innerHTML= (Math.random() * (6 - 1) + 1)+6;
document.getElementById('constition').innerHTML= (Math.random() * (6 - 1) + 1)+6;
document.getElementById('wisdom').innerHTML= (Math.random() * (6 - 1) + 1)+6;
document.getElementById('intelligence').innerHTML= (Math.random() * (6 - 1) + 1)+6;
document.getElementById('charaisma').innerHTML= (Math.random() * (6 - 1) + 1)+6;
}
else if(char_class = "symbol") { //if user selects symbol character class
var s = random();
s = String.fromCharCode(s.charCodeAt(0) + 6)
document.getElementById('strength').innerHTML= s;
var d = random();
d = String.fromCharCode(d.charCodeAt(0) + 6);
document.getElementById('dexterity').innerHTML= d;
var c = random();
c = String.fromCharCode(c.charCodeAt(0) + 6);
document.getElementById('constition').innerHTML= c;
var w = random();
w = String.fromCharCode(w.charCodeAt(0) + 6);
document.getElementById('wisdom').innerHTML= w;
var i = random();
i = String.fromCharCode(i.charCodeAt(0) + 6);
document.getElementById('intelligence').innerHTML= i;
var ch = random();
ch = String.fromCharCode(ch.charCodeAt(0) + 6)
document.getElementById('charaisma').innerHTML= ch;
}
}
function random () { //function to generate random character between A and F
var sym = "";
var data = "ABCDEF";
for( var i=0; i < 6; i++ )
sym += data.charAt(Math.floor(Math.random() * data.length));
return sym;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.