Hello again @mikoMK, and hello @justsomeone!
I think I understand what you both are saying. Maybe. Sort of. You tell me.
I believe that, according to you miko (Michael? Mikey Mike?), I need to change low to 0. Does that mean I need to actually change low to 0, or does that mean I can keep low but change the parameter to 0 when I call the function? I think it’s confusing me because I was under the impression that “generic” meant “in general terms”, so like, doing what I did in my original code instead of using numbers. So is that incorrect?
However, your comment about not including ‘Chris’ helped it make sense I think… Since I was using names[0], I wasn’t starting at 0 but at Chris?
Okay, I’m still doubting whether I’ve fixed it properly or not. However, the code works (I made sure that all names can show up), so I’m crossing my fingers.
And I appreciate the further input @justsomeone. I was brainfarting on that part of the instructions, but your comment actually helped me see clearly.
Here’s my revision. I’m still confused about the word “generic”, so feel free to correct me further.
let names = ['Chris', 'Li Kang', 'Anne', 'Francesca', 'Mustafa', 'Tina', 'Bert', 'Jada']
let para = document.createElement('p');
// My code
function random(low, high) {
return Math.floor(Math.random()*high);
}
function chooseName(names) {
let newVar = random(0, names.length);
return names[newVar];
}
para.textContent = chooseName(names);
// End of my code
section.innerHTML = ' ';
section.appendChild(para);
(please oh please let me be closer and not further
I’m having trouble with JS because it’s my first real programming language, but I feel like I’m slooowly starting to understand it.)