JSFiddle - React, Tailwind, and code Playground
by Gatsu35
HTML
<img src="Alexs_face.png">
<p style="border:2px black solid; margin:100px 400px 50px 400px">Ask me !</p>
<p id="lable"></p>
<input id="input" type="text" >
<input id="send" type="button" onclick="getVal();write(x)" value="Send">
<input id="delete" type="button" onclick="" value="Delete">
CSS
body {
text-align:center; background-color:grey; color:white;
}
JavaScript
function getVal() {
var ask = document.getElementById("input").value;
return ask ;
}
var ask = getVal();
var x;
//var ask = prompt ("Ask me anything >>").toLowerCase ();
function write (x){
var lable = document.getElementById("lable").innerHTML = x;
return lable ;
};
//Capitalize the first letter func :
function capitalize(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
//..............
var question = ask.split(" ");
var date = new Date ;
//var userName ;
//...............................
if (question[0] === "what"){
switch ( question[1]){
case "time":
switch (question[2]){
case "is":
switch (question[3]){
case "it":
write("Hi , the time is :"+date);
break;
default:
};
break;
default:
} ;
break;
case "is":
switch (question[2]){
case "your" :
switch (question[3]){
case "name":
write("Alex !");
break;
default:
};
break;
default:
};
break;
default: write("unknown");
};}
else if (question[0] === "my"){
switch (question[1]){
case "name":
switch(question[2]){
case "is":
userName = capitalize(question[3]);;
alert("Your name is saved, "+userName);
function sendUserName(){
return userName ;
}
break;
default:
};
break;
default:
};
}
else if (question[0] === "should" || "could" || "may" || "can" ) {
switch (question[1]) {
case "i" :
switch(question[2]){
case "sleep":
write("Sure ! you can sleep if you want to !!");
...