Skip to content

Commit 853d40a

Browse files
committed
coding
1 parent 7f6911a commit 853d40a

11 files changed

Lines changed: 235 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
# Working with Basic Data Types Activity
2+
creating a short story using basic data types.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// TODO: Create 4-String variables to introduce develop your story.
2+
// YOUR CODE GOES HERE
3+
let title = "Founder";
4+
let name = 'Vylin';
5+
let greetings = "Hello all! I'm Vylin, founder of life on earth.";
6+
let power = 'creation';
7+
8+
// TODO: Create 3-String variables to set the time period of your story or discuss other number elements.
9+
// YOUR CODE GOES HERE
10+
let year = 2099;
11+
let age = 999999999999;
12+
let century = 20;
13+
14+
15+
// TODO: Create 1-Array variable to show a collection of items your character might have.
16+
// YOUR CODE GOES HERE
17+
let weapons = ['dagger', 'scythe', 'bow', 'falchion', 'two bladed sword'];
18+
19+
// TODO: Create 1-Boolean variable to demonstrate a true or false scenario.
20+
// YOUR CODE GOES HERE
21+
let destroyedEarth = true;
22+
23+
// TODO: Print your story to the console.
24+
// YOUR CODE GOES HERE
25+
26+
27+
console.log(title);
28+
console.log(greetings);
29+
console.log("I came about with the power " + power);
30+
console.log("Although, I do not know how or why I came into this corrupt world");
31+
console.log("It is now the year " + year + ", we are in the 20th century... I believe-");
32+
console.log("Besides the that I am " + age + " years old. I know i'm about to be 10 trillion soon");
33+
console.log("someone random: Imagine being that old, I could never-");
34+
console.log("vylin: ... wha-");
35+
console.log("vylin: kids these days I tell you. So disrepectful -.-");
36+
console.log("Anyways, like I was saying before I was rudely interuppted");
37+
console.log("I am " + age);
38+
console.log("I lived throughout all watching the humans as one or from above.");
39+
console.log("I still have all my weapons I made from being disguised as a human");
40+
console.log("Each weapon of mine (" + weapons + ") each have an ounce of my power in them.");
41+
console.log("So wholesome right ;)");
42+
console.log("same random hater (aka the kid): no. not cool at all man");
43+
console.log("vylin: I'm going to provoke your speaking rights kid -.-");
44+
console.log("same random kid: man, did you not destroy all of earth because, US humans,");
45+
console.log("were causing problems you didn't like or whatever-");
46+
console.log("vylin: ... well yes, thats " + destroyedEarth);
47+
console.log("BUT its entirely all of y'alls fault. dumping trash everywhere, harming animals, you already know the rest.");
48+
console.log("Concluding this short (i'm lying. its not short at all-) introduction");
49+
console.log("featuring a child who needs to have no more speaking rights");
50+
console.log("I hope you enjoyed this and be thankful I helped earth-");
51+
console.log("same kid: man why is you lyin-");
52+
console.log("vylin: That's all. Thank you for sparring me time :D");
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
# Creating Sentences Activity
2+
turning elements into sentences.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// TODO: Create an array variable called "words" with the following elements: 'This', 'is', 'JavaScript', 'Coding!'
2+
// YOUR CODE GOES HERE
3+
let words = ["This", "is", "JavaScript", "Coding!"]
4+
5+
// TODO: Create an empty string variable called "sentence".
6+
// YOUR CODE GOES HERE
7+
let sentence = " "
8+
9+
// TODO:
10+
// 1. Create a function called "createSentence" that takes an array as an argument.
11+
// 2. In the function use a for loop to iterate through each word element of the array.
12+
// 3. Add each word to the "sentence" variable.
13+
// 4. Return the "sentence".
14+
// YOUR CODE GOES HERE
15+
function createSentence(words) {
16+
for(index = 0; index <= words.length-1; index++){
17+
(sentence) = sentence + words[index] + " "
18+
//console.log(sentence)
19+
}
20+
return sentence
21+
}
22+
// TODO: Call the function "createSentence" using the console.log method.
23+
// YOUR CODE GOES HERE
24+
console.log(createSentence(words))

Debugging Activity/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
# Debugging Activity
2+
debug codes.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* Description: This program is locked into an infinite loop. Your task is to run and debug the program.
3+
*
4+
* TODO: The program should exit the loop after counting down from 5 to 1.
5+
* You should check to make sure the boolean statement
6+
* is being updated.
7+
*/
8+
9+
function checkPoint1() {
10+
alert1();
11+
12+
let array = [];
13+
let x = 5;
14+
15+
// TODO: Remove the bugs from the code below.
16+
function getMultiples() {
17+
while (x >= 1){
18+
array.push(x);
19+
x = x - 1
20+
}
21+
return array;
22+
}
23+
console.log(getMultiples());
24+
25+
// DO NOT CHANGE THE CODE BELOW
26+
alert2();
27+
}
28+
29+
30+
/************************************************ DONT CHANGE THE CODE BELOW ******************************************************/
31+
function alert1() {
32+
alert("Oh no! It looks like you are trapped in an infinite loop. Go to the example1.js file and work on checkpoint 1.");
33+
}
34+
35+
function alert2(){
36+
alert("Congratulations! You have passed checkpoint 1!");
37+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* Description: This program is assigning student IDs to 5 new students but there is a bug in the code preventing the code to run
3+
* as expected. Your task is to run and debug the program using breakpoints.
4+
*
5+
* TODO: The program has error message in the console. You should read the message and debug accordingly. The final
6+
* goal is to print out a student ID for each student to the console. The ID numbers should be from 0 to 4.
7+
*/
8+
9+
function checkPoint2(){
10+
alert3();
11+
12+
// TODO: Remove the bugs from the code below.
13+
const friends = ["Rei", "Miya", "Alexis", "Ethan", "Anna"];
14+
const studentID = [];
15+
16+
for (let i = 0; i < friends.length; i++){
17+
studentID.push("JSMIT");
18+
}
19+
console.log(studentID);
20+
21+
// DO NOT CHANGE THE CODE BELOW
22+
alerts(studentID);
23+
}
24+
25+
26+
/************************************************ DONT CHANGE THE CODE BELOW ******************************************************/
27+
function alert3() {
28+
alert("All students need to get their student IDs, but it seems like the system is down. Can you help debug the system? Go to the example2.js file and work on checkpoint 2.");
29+
}
30+
31+
function alerts(studentID) {
32+
if (studentID.length == 5) {
33+
alert("Yay! You got the system running!");
34+
}
35+
else {
36+
alert("Hmmm! It seems like Rei hasn't received his ID. Keep debugging!");
37+
}
38+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* Description: This program is calculating the amount of change given to the customer after buying groceries but there is a bug
3+
* in the code preventing the code to run as expected. Your task is to run and debug the program using the console to print
4+
* statements.
5+
*
6+
* TODO: The program currently displays NaN in the console as the returned change. You should check and make sure the function
7+
* is reading the passed parameters.
8+
*/
9+
10+
function checkPoint3(){
11+
alert4();
12+
13+
// TODO: Remove the bugs from the code below.
14+
function superMarket(cash) {
15+
let milk = 4.99;
16+
let vegetables = 15.99;
17+
let bread = 2.99;
18+
19+
let total = milk + vegetables + bread;
20+
cash = cash - total;
21+
22+
return cash;
23+
}
24+
25+
function main(cash) {
26+
let moneySpent = superMarket(cash);
27+
return moneySpent;
28+
}
29+
30+
let totalCash = 50.00;
31+
console.log("Total Cash: $" + totalCash);
32+
console.log("Change Return = $" + main(totalCash));
33+
34+
35+
36+
// DO NOT CHANGE THE CODE BELOW
37+
if (main(totalCash) < 50) {
38+
alert("Awesome work! You got the system running!");
39+
}
40+
}
41+
42+
43+
/************************************************ DONT CHANGE THE CODE BELOW ******************************************************/
44+
function alert4() {
45+
alert("The system at the supermarket doesn't seem to be working. Can you help debug the system to help calculate the total change return to the customer? Go to the example3.js file and work on checkpoint 3.");
46+
}

Fortune Teller Activity/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
# Fortune Teller Activity
2+
fortune teller game.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// TODO: Create a variable called "fortune" and assign a number between 0 - 10.
2+
// YOUR CODE GOES HERE
3+
var fortune = 10
4+
5+
// TODO: Create a fortune teller game using conditional statements and comparison operators.
6+
// Conditions
7+
// 1. If fortune is greater than or equal to 0 and less than or equal to 3, then you have a low fortune.
8+
// 2. If fortune is greater than 3 and less than or equal to 7, then you have an average fortune.
9+
// 3. If fortune is greater than 7 and less than or equal to 10, then you have a good fortune.
10+
// 4. If the fortune is out of range, then the fortune can't be read correctly.
11+
12+
// YOUR CODE GOES HERE
13+
14+
if(fortune >= 0 && fortune <= 3)
15+
16+
{
17+
console.log("Unfortunately, you have a low fortune")
18+
}
19+
20+
else if(fortune > 3 && fortune <= 7)
21+
{
22+
console.log("You have an avergae fortune!")
23+
}
24+
25+
else if(fortune > 7 && fortune <= 10)
26+
{
27+
console.log("Good job, you have a good fortune!")
28+
}
29+
30+
else
31+
{
32+
console.log("Sadly the fortune was unidentified; out of range")
33+
}

0 commit comments

Comments
 (0)