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
Empty file added anhtony-crowley
Empty file.
90 changes: 79 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,38 @@
/************************************************************** 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;




/************************************************************** 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



Expand Down Expand Up @@ -60,32 +66,77 @@
// 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
}



/************************************************************** Task 6 **************************************************************/
// 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
Expand All @@ -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");
}



Expand Down