Skip to content

Commit

Permalink
add files
Browse files Browse the repository at this point in the history
  • Loading branch information
ebunilo committed Dec 24, 2022
1 parent e006f9d commit a446080
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 59 deletions.
21 changes: 21 additions & 0 deletions javascript/function.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>

<body>
<script>
function sumNum(num1, num2) {
sum = num1 + num2;
return sum;
}
console.log(sumNum(2, 5));
</script>
</body>

</html>
137 changes: 80 additions & 57 deletions javascript/selection.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,77 +13,100 @@ <h1>Selection</h1>

<script>
/* var red = true;
var blue = false;
var green;
var num = 5;
var otherNum = 6;
var notNum = "5" */
var blue = false;
var green;
var num = 5;
var otherNum = 6;
var notNum = "5" */
// num == notNum (true) Type coercion
// num === notNum (false)

/* if (num == otherNum) {
console.log("Statement is true");
} else {
console.log("Statement is false");
} */

var colours = ["red", "green", "blue", "yellow"];
var selectedColour = colours[1];

/* if (selectedColour === "red") {
console.log("The selected colour is red");
} else if (selectedColour === "green") {
console.log("The selected colour is green");
} else if (selectedColour === "blue") {
console.log("The selected colour is blue");
} else if (selectedColour == "yellow") {
console.log("The selected colour is yellow");
} else {
console.log("The selected colour is not in the list");
} */
console.log("Statement is true");
} else {
console.log("Statement is false");
} */

/* var colours = ["red", "green", "blue", "yellow"];
var selectedColour = colours[1];
if (selectedColour === "red") {
console.log("The selected colour is red");
} else if (selectedColour === "green") {
console.log("The selected colour is green");
} else if (selectedColour === "blue") {
console.log("The selected colour is blue");
} else if (selectedColour == "yellow") {
console.log("The selected colour is yellow");
} else {
console.log("The selected colour is not in the list");
} */

/* switch (selectedColour) {
case "red":
console.log("the colour is red");
break;
case "green":
console.log("the colour is green");
break;
case "blue":
console.log("the colour is blue");
break;
case "yellow":
console.log("the colour is yellow");
break;
default:
console.log("there was an error");
} */
case "red":
console.log("the colour is red");
break;
case "green":
console.log("the colour is green");
break;
case "blue":
console.log("the colour is blue");
break;
case "yellow":
console.log("the colour is yellow");
break;
default:
console.log("there was an error");
} */

/* var goodMood = false;
var gotSleep = false;
var gotPaid = false;
var gotSleep = false;
var gotPaid = false;
if (goodMood || gotSleep || gotPaid) {
console.log("Today is a good day");
} else {
console.log("I am grumpy");
} */
if (goodMood || gotSleep || gotPaid) {
console.log("Today is a good day");
} else {
console.log("I am grumpy");
} */

/* for (i = 0; i <= 10; i++) {
console.log(i);
} */
console.log(i);
} */

/* var food = ["garri", "beans", "yam", "corn"];
for (var eachItem of food) {
console.log(eachItem);
} */
var i = 0;
var text = "";
while (i < 10) {
text += "The incrementor has gone up by " + i + "\n";
i++;
for (var eachItem of food) {
console.log(eachItem);
} */
/* var i = 0;
var text = "";
while (i < 10) {
text += "The incrementor has gone up by " + i + "\n";
i++;
}
console.log(text); */

var myString = "I'm really hungry for some ";
console.log(myString);
var myUpperString = myString.toUpperCase();
console.log(myUpperString);

var foods = ["eba", "yam", "beans", "plantain"];
// use string literal syntax to print myString and first item in foods
console.log(`${myString} ${foods[0]}`);

// use loop to print myString and each value in foods
for (i = 0; i < foods.length; i++) {
console.log(`${myString} ${foods[i]}`);
}

//if index in foods is even, convert to uppercase, else don't convert
for (i = 0; i < foods.length; i++) {
if (i % 2 === 0) {
console.log(`${myString} ${foods[i].toUpperCase()}`);
} else {
console.log(`${myString} ${foods[i]}`);
}
}
console.log(text);
</script>
</body>

Expand Down
37 changes: 35 additions & 2 deletions javascript/testing.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
for (var i = 0; i < 10; i++) {
/* for (var i = 0; i < 10; i++) {
console.log(i);
}
} */

/* function nitdaAccepted() {
console.log("Congrats, you have been accepted into NBS");
console.log("Enroll to Bitcoin Theory course at 5thwork.com");
}
nitdaAccepted(); */

/* ar numArray = [1, 2, 3, 4, 5, 6, 7, 8, 9];
function evenNumbers(arr) {
for (i = 0; i < arr.length; i++) {
if (arr[i] % 2 === 0) {
console.log(arr[i]);
}
}
}
evenNumbers(numArray); */

/* function sumNum(num1, num2) {
var sum = num1 + num2;
return sum;
}
console.log(sumNum(5, 7)); */

var a = ["a", "b", "c", "d"];
var i = 0;
while (a[i]) {
i++;
}
console.log(i);

1 comment on commit a446080

@Abkjikanda
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

java script file

Please sign in to comment.