I'll try to explain as best as I can because I cannot find this anywhere.
I'm making a simple dice rolling script.
function rollDice(number, sides) {
return("Rolled (number) (sides) sided dice")
}
so when I type the command for an example rollDice(1, 5) I want it to input "Rolled one five sided dice" but I don't know how to input the (number, sides) into the return command.
EDIT: The question has been answered, I used this
var names = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty'];
function rollDice(number, sides) {
return("Rolled "+ names[number] +" "+ names[sides] +" sided dice");
}
to convert the numbers into words and to input (number, sides) into the 'return' command.
If anyone will look back at this tho, I'm having another problem, I want to input arguments of a previous function inside my new function, but it's returning an error:
function randomNum(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function randomDice(number, sides) {
randomNum(+number+, +sides+);
}
randomDice(1, 5)
the part that gives me the error is:
function randomDice(number, sides) {
randomNum(+number+, +sides+);
}
Thank you for the help