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
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<title>Document</title>
</head>
<body>
<h1>Hello World</h1>
<script src="index.js"></script>
</body>
</html>
58 changes: 52 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,49 @@
/************************************************************** Task 1: Warm-up! **************************************************************/
//Task a: declare a variable called votingAge, console log true if age > 18 (no function required)

var votingAge;

votingAge = prompt("What is your age?");

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

else {
console.log("False");
}

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


//Task b:
//declare a variable
var myVariable = "He or she is NOT an adult person";
//and then use a conditional to change the value of that variable based on the value assigned to a second variable (no function required)
if (votingAge > 18) {
myVariable = "He or she is an Adult person";
console.log(myVariable);

} else {
console.log(myVariable);
}


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



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

let year = "1999";
console.log(Number(year));

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


//Task d: Write a function to multiply a*b
function multiply(a, b) {
//Return the sum
return a*b;
}
var product= multiply(10, 4);
console.log(product);



Expand All @@ -28,9 +52,13 @@
//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


function calculate() {
var humanYears = 10 ;
var dogYears = (humanYears * 7);
console.log(dogYears);
}



console.log(calculate());
/************************************************************** Task 3 **************************************************************/
//Dog feeder
//takes weight in pounds and age in years (note if the dog is a puppy the age will be a decimal) and returns the number of pounds of raw food to feed in a day.
Expand Down Expand Up @@ -67,12 +95,30 @@
//Metric Converter
//a. KM to Miles - should take the number of kilometers and convert it to the equal number of miles

function calculate() {
var kilometers = 1 ;
var miles = (kilometers / 0.62137119223);
console.log(miles);
}

console.log(calculate());





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

function calculate() {
var centimeters = 1 ;
var feet = (centimeters * 30,48);
console.log(feet);
}

console.log(calculate());






Expand Down