Click here to Skip to main content
15,867,911 members
Home / Discussions / JavaScript
   

JavaScript

 
GeneralRe: New to Coding Pin
John Wiser25-Jul-22 9:44
John Wiser25-Jul-22 9:44 
AnswerRe: New to Coding Pin
Jeremy Falcon26-Oct-22 11:49
professionalJeremy Falcon26-Oct-22 11:49 
QuestionI need help with a task Pin
User 1567076221-Jul-22 11:35
User 1567076221-Jul-22 11:35 
AnswerRe: I need help with a task Pin
jeron121-Jul-22 11:56
jeron121-Jul-22 11:56 
GeneralRe: I need help with a task Pin
jsc4225-Jul-22 4:11
professionaljsc4225-Jul-22 4:11 
QuestionI need help with an Javascript exercise! Pin
User 1567076215-Jul-22 20:39
User 1567076215-Jul-22 20:39 
GeneralRe: I need help with an Javascript exercise! Pin
Richard MacCutchan15-Jul-22 21:29
mveRichard MacCutchan15-Jul-22 21:29 
GeneralRe: I need help with an Javascript exercise! Pin
User 1567076215-Jul-22 22:59
User 1567076215-Jul-22 22:59 
function colorSelector (colorCode) {

let randomNumber = Math.floor((Math.random() * 100));

if (randomNumber < 10) {
    console.log("green");
}

else if (randomNumber >= 10 && randomNumber < 19) {
    console.log("yellow");
}

else if (randomNumber > 19) {
    console.log("blue");
}


return (randomNumber);


}

console.log(colorCode);


This is how far I got. Im confused what should be inside the function and what should we outside. Im also not sure if im using the return operator the right way.

modified 29-Aug-22 21:01pm.

GeneralRe: I need help with an Javascript exercise! Pin
Richard MacCutchan15-Jul-22 23:09
mveRichard MacCutchan15-Jul-22 23:09 
GeneralRe: I need help with an Javascript exercise! Pin
Eddy Vluggen16-Jul-22 3:53
professionalEddy Vluggen16-Jul-22 3:53 
GeneralRe: I need help with an Javascript exercise! Pin
Richard MacCutchan16-Jul-22 4:18
mveRichard MacCutchan16-Jul-22 4:18 
GeneralRe: I need help with an Javascript exercise! Pin
Eddy Vluggen16-Jul-22 4:46
professionalEddy Vluggen16-Jul-22 4:46 
GeneralRe: I need help with an Javascript exercise! Pin
Richard MacCutchan16-Jul-22 4:51
mveRichard MacCutchan16-Jul-22 4:51 
GeneralRe: I need help with an Javascript exercise! Pin
Eddy Vluggen16-Jul-22 5:00
professionalEddy Vluggen16-Jul-22 5:00 
AnswerRe: I need help with an Javascript exercise! Pin
Gerry Schmitz16-Jul-22 5:49
mveGerry Schmitz16-Jul-22 5:49 
Questionextract value from json Object in Node JS Pin
janaswamy uday12-Jul-22 7:23
janaswamy uday12-Jul-22 7:23 
AnswerRe: extract value from json Object in Node JS Pin
Ben Code15-Aug-22 23:59
Ben Code15-Aug-22 23:59 
QuestionWebView2 - Send Script with a Value Pin
Alan Burkhart5-Jul-22 9:28
Alan Burkhart5-Jul-22 9:28 
AnswerRe: WebView2 - Send Script with a Value Pin
Richard Deeming7-Jul-22 2:19
mveRichard Deeming7-Jul-22 2:19 
GeneralRe: WebView2 - Send Script with a Value Pin
Alan Burkhart7-Jul-22 14:05
Alan Burkhart7-Jul-22 14:05 
GeneralRe: WebView2 - Send Script with a Value Pin
Richard Deeming7-Jul-22 21:42
mveRichard Deeming7-Jul-22 21:42 
GeneralRe: WebView2 - Send Script with a Value Pin
Alan Burkhart8-Jul-22 0:24
Alan Burkhart8-Jul-22 0:24 
QuestionRotate text Pin
Rockallica13-Jun-22 13:57
Rockallica13-Jun-22 13:57 
AnswerRe: Rotate text Pin
Graham Breach13-Jun-22 20:58
Graham Breach13-Jun-22 20:58 
GeneralRe: Rotate text Pin
Rockallica14-Jun-22 8:38
Rockallica14-Jun-22 8:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.