Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}
53 changes: 47 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,49 @@
/************************************************************** Task 1: Warm-up! **************************************************************/
//Task a: declare a variable called votingAge, console log true if age > 18 (no function required)

var votingAge = 19;
if (votingAge > 18) {
console.log("True");
}




//Task b: declare a variable and then use a conditional to change the value of that variable based on the value assigned to a second variable (no function required)

var a = 5;
var b = 3;
if ( a > b) {
a = 10
}




//Task c: Convert string ("1999") to integer (1999) (no function required) // hint look up the Number method


var toInt = "1999";
Number(toInt);



//Task d: Write a function to multiply a*b


function multi(a , b) {
console.log(a*b);
}
multi(5,2);



/************************************************************** Task 2 **************************************************************/
//Age in Dog years
//write a function that takes your age and returns it to you in dog years - they say that 1 human year is equal to seven dog years

var age = 21;

function dogAge (a) {
console.log(a*7);
}

dogAge(age);



Expand Down Expand Up @@ -60,19 +76,44 @@
// use math.random to determine the computers choice
// hint while you can complete this with only conditionals based on strings it may help to equate choice to a number

function RPSGame() {
var userInp = prompt("Do you want to choose: '1. Rock' '2. Paper' or '3. Scissors' ?");
var compInp = Math.random()*3;
compInp = Math.round(compInp);
console.log(compInp)
if (compInp <= 1) {
console.log("The computer chose Rock!");
} else if (compInp === 2){
console.log("The computer chose Paper!");
} else {;
console.log("The computer chose Scissors!");
}
if (userInp < compInp) {
console.log("You lost! Better luck next time!");
} else if (userInp === compInp) {
console.log("You tied!");
} else if (userInp > compInp){
console.log("You won! Congratulations!");
}
}

RPSGame();


/************************************************************** Task 5 **************************************************************/
//Metric Converter
//a. KM to Miles - should take the number of kilometers and convert it to the equal number of miles
var km = prompt("How many km do you wish to convert: ");

console.log(km + "kms is " + km*0.621371 + " in miles!");




//b. Feet to CM - should take the number of feet and convert it to the equal number of centimeters

var feet = prompt("How many feet do you wish to convert: ");

console.log(feet + " feet is " + feet*30.48 + " in centimeters!");



Expand Down