From 66fd86f1f297d77ecc42574d164e19469ec3b738 Mon Sep 17 00:00:00 2001 From: MrACrowley Date: Tue, 25 Aug 2020 18:50:57 -0400 Subject: [PATCH] done --- anhtony-crowley | 0 index.js | 90 +++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 79 insertions(+), 11 deletions(-) create mode 100644 anhtony-crowley diff --git a/anhtony-crowley b/anhtony-crowley new file mode 100644 index 000000000..e69de29bb diff --git a/index.js b/index.js index 73f240372..9be303314 100644 --- a/index.js +++ b/index.js @@ -1,24 +1,28 @@ /************************************************************** Task 1: Warm-up! **************************************************************/ //Task a: declare a variable called votingAge, console log true if age > 18 (no function required) - +const age= "18" //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 name=Jack +name=Anthony //Task c: Convert string ("1999") to integer (1999) (no function required) // hint look up the Number method - +const year= "1999" +const yearasNumber= Number(year) //Task d: Write a function to multiply a*b - +var a= 5; +var b= 10; +var c= a * b; @@ -26,7 +30,9 @@ /************************************************************** 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 = 36 +var myageasdog = age/7 @@ -60,20 +66,48 @@ // 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 - +// rules +//rock beats scissors +//paper beats rock +//scissors beats paper +const rock = 1; +const paper = 2; +const scissors = 3; +function rockpaperscissors(options){ + const choice = Math.random() * 4; + const choice = Math.floor(choiceRaw); + + if (options === "rock" && choice === 2){ + console.log("You lose"); + } + + else if (options === "rock" && choice === 3){ + console.log( "You win"); + } + + else (options === "rock" && choice === 1){ + console.log( "Draw"); + } +} + console.log(choices) /************************************************************** Task 5 **************************************************************/ //Metric Converter //a. KM to Miles - should take the number of kilometers and convert it to the equal number of miles - - +function lengthConverter (valNum) +{ + document.getElementById("outputMiles").innerHTML =valNum /.62137 +} //b. Feet to CM - should take the number of feet and convert it to the equal number of centimeters - +function lengthConverter (valNum) +{ + document.getElementById("outputCentimeters").innerHTML =valNum /.032808 +} @@ -81,11 +115,28 @@ // 99 bottles of soda on the wall // create a function called annoyingSong // the function should take a starting number as an argument and count down - at each iteration it should log (number) bottles of soda on the wall, (number) bottles of soda, take one down pass it around (number left over) bottles of soda on the wall` - - - +var bottles; +for ( counter = 99; counter >= 1; +counter = counter - 1 ) +{ +if (counter === 1){ + bottles ='bottle'; +} else { + bottles = 'bottles' +} +console.log(counter+" "+bottles+"of soda on the wall."); +if (counter < 99); + console.log(""); + console.log(counter+""+bottles+"of soda on the wall."); + + console.log("Take one down"); + console.log("Pass it around"); + if (counter === 1) { + console.log("No bottles of soda on the wall."); + } +} /************************************************************** Task 7 **************************************************************/ //Grade Calculator //write a javaScript program that takes a mark out of 100 and returns a corisponding letter grade @@ -95,6 +146,23 @@ //60s should be D //and anything below 60 should be F +console.log(Average grade: + (Avgmarks)/student.length); + +if (avg < 60) { + console.log ("Grade=F"); +} +else if (avg < 70) { + console.log ("Grade=D"); +} +else if (avg < 80){ + console.log ("Grade=C"); +} +else if (avg < 90){ + console.log ("Grade=B"); +} +else ( avg < 100){ + console.log ("Grade=A"); +}