mardi 27 octobre 2020

Call function if-statement is true before the function has declared

I am trying to call a function if-statement is true before the function has declared as shown in the example below

This is the general idea of the code, any suggestion? let me know if you have any questions. Thanks

function start(){

var a=Math.random();
var b=Math.random();

if (a>b) function one();
else function two();

function one(){ //do something}
function two(){//do something}
}

start(); 

Aucun commentaire:

Enregistrer un commentaire