JSFiddle - React, Tailwind, and code Playground

by Dimitri Anoudis

HTML

<html>
<head>
    <title></title>
</head>
<body>
  <p id="name"></p>
  <p id="address"></p>
  <p id="age"></p>
  
  <p id="results"></p>
</body>
</html>

JavaScript

var theResults = [];

var hash = { 
    "funcA": funcA,
    "funcB": funcB,
    "funcC": funcC
};

function funcA(value) {
 var person = prompt("Please enter your name", "eg Dimitri");
  if (person != null) {
    document.getElementById("name").innerHTML =
    "Hello " + person + "! How are you today?";
  }
}
function funcB(value) {
   var address = prompt("Please enter your address", "eg Old Street");
  if (address != null) {
    document.getElementById("address").innerHTML =
    "Hello your address is:" + address + "";
  }
}
function funcC(value) {
  var age = prompt("Please enter your age", "eg 20");
  if (age != null) {
    document.getElementById("age").innerHTML =
    "Hello your age is:" + age + "";
  }
}

var promise1 = funcA().then(function (value) {
    return value;
});
var promise2 = funcB().then(function (value) {
    return value;
});
var promise3 = funcC().then(function (value) {
    return value;
});

$q.all([promise1, promise2, promise3]).then(function(result){
    for (var i = 0; i < result.length; i++){
        theResults.push(result[i]);
        document.getElementById("results").innerHTML = theResults;
    }
});