Skip to content

Commit

Permalink
Testing node for a bit more
Browse files Browse the repository at this point in the history
  • Loading branch information
tungstengmm committed Apr 25, 2024
1 parent adca53f commit e5123c2
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 1 deletion.
5 changes: 4 additions & 1 deletion node.js
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
return("this is a test")
function test(word) {
return(`this is a test, $(word)`);
}
test(`user`)
87 changes: 87 additions & 0 deletions nodified.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
startScript = readline("Which script should be started? Answer with 1 to 10 respectively. The scripts are: the multiplier, the one that states your favourite colour, the name swapper, the little test I made, the weekly pay calculator, the address formatter, the Uber® fare calculator, my while loop test, the number detector and the time table reciter.");
switch (startScript) {
case "1":
number1 = readline("What number do you wish to multiply?");
number2 = readline("What are you multiplying it by?");
alert(`The answer is ${number1 * number2}.`);
break;
case "2":
colour = readline("What's your favourite colour?");
return(`Your favourite colour is ${colour}.`);
break;
case "3":
firstName = readline("What's your first name?");
lastName = readline("What's your last name?");
return(lastName + " " + firstName);
break;
case "4": //this was an if statement test
alert("Hello! This is a text box. I think it's kinda neat.");
readlines = readline("is this cool?");
readline("How could this be improved?");
alert("I will take note of that. (in other words it isn't stored anywhere :3)");
break;
case "5":
hourlyRate = readline("Input your hourly rate.");
hoursWorked = readline("Input how long you work.");
alert(`Your weekly pay is £${hourlyRate * hoursWorked} per week.`);
break;
case "6":
housenumber = readline("Enter your house number.");
street = readline("Enter your street.");
town = readline("Enter your town.");
town = town.charAt(0).toUpperCase + town.slice(1); //capitalises first letter by slicing it off and replacing it
house = housenumber + ", " + street + ", " + town;
alert(`You live at ${house}.`);
break;
case "7":
distance = parseFloat(readline("How far is your journey?"));
time = parseFloat(readline("How long will it take?") * 0.1);
fare = time + distance + 1.1;
if (fare < 2.5) {
console.error("PRICE TOO LOW; SWITCHING TO MINIMUM FARE...");
alert("Your fare is £2.50");
} else {
alert(`Your fare is £${fare.toFixed(1)}0.`);
}
break;
case "8":
random = Math.floor(Math.random() * 10);
console.log(`Shh! The number is ${random}. Don't tell anyone!`);
guess = readline("Guess my lucky number!");
times = 1;
while (guess != random) {
if (guess < random) {
guess = readline("Wrong! The answer is higher!");
} else {
guess = readline("Wrong! The answer is lower!");
}
times++;
console.error("You suffer from a severe case of skill issue.");
};
alert("YIPPEEEEEEEEEEEEEEEEE!!!!!!!!!!!!!");
console.log(`The amount of tries needed for this to succeed were: ${times}`);
break;
case "9":
number = readline("Gimme a number.");
if (number % 2 == 0) { //the percent sign sends the remainder back with modulus
alert("That's an even number or smth idk i forgor mdgkjbhdsmbj");
} else if (number % 2 == 1) {
alert("you are one silly oddball. Or are you, perhaps, an odd sphere? *vsauce theme plays*");
}
break;
case "10":
table = window.readline("Which times table?");
for (let index = 0; index <= 12; index++) {
let answer = index * table;
return(parseInt(index) + "x" + parseInt(table) + "=" + answer + "<br>");
}
break;
default:
alert("You need to pick one. Let's try again, shall we?");
location.reload();
}
console.log("What are you doing around here?");
//TODO: add more scripts
//jamie for the love of god learn js
//written with far
//ngl this code makes me want to kiss boys :3

0 comments on commit e5123c2

Please sign in to comment.