# Creating an array of randomly generated numbers

Creating an array of randomly generated numbers
0

Wondering what is wrong with the functions aimed to generate three random numbers in the range of 1-10, and displaying them to the console in a string of its own created from an array.

``````
function randNumberX()   {
1 + Math.floor(10 * Math.random());
}
function genMathDrop()    {
var randDrop = [
randNumberX(),
randNumberX(),
randNumberX()
]
var randDropStr = randDrop[0] + randDrop[1] + randDrop[2];
console.log(randDropStr);
}
genMathDrop();
``````

what does your function `randNumberX` returns?
can you quote the return statement of that function?

1 Like

It is supposed to return a random number in range of 1-10. I donâ€™t know what you mean by quote the return statement.

so, above, you have a function. That function does, in fact, calculate a value between 1 and 10 - but it does nothing with that value. When @ieahleen asked you about the return statement, thereâ€™s a point. Every function returns a value, even if we donâ€™t specifically say `return`. If we donâ€™t `return` some value, our function still will return something - if we donâ€™t specify, it will return `undefined`.

So hereâ€™s an example:

``````function myFunctionThatReturnsSomething(){
const returnedValue = 'I am a string.';
return returnedValue;
};
``````

This function, when called, `return`s a value. That value is a string, so we can do

``````const myStringyThing = myFunctionThatReturnsSomething();
// now, myStringyThing === 'I am a string.'
``````

So, in the function I quoted at the top of this, you have a mathematical expression, but you donâ€™t actually return the value youâ€™ve just calculated. Can you figure how to do that?

For the record, this is exactly the kind of thing the FCC javascript track can help you to learn.

1 Like

Yes Iâ€™ve changed the code now, Iâ€™ve actually done the FCC JS basics, just still very crude with writing correct syntax as it is still very new to me. I appreciate the help.

Itâ€™s the â€śHow do you get to Carnegie Hall?â€ť question: â€śpractice, practice, practice.â€ť

Youâ€™re doing fine, and I thought I remembered seeing a few posts from you regarding JS - just keep plugging, and keep asking questions. It takes time to learn, and javascript can be a funny language.

1 Like

Thank you sir. yes I am writing some code to apply the lessons Iâ€™ve learnt here.