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
27 changes: 27 additions & 0 deletions 01week/javascripting/hungergames.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict';

/**
* pick a ronadom student from this class
*
* store names in a variable- array
*
* generate a random number, less than amount in class
*
* apply the index to the array
*
* from that array, pick a random one
*
* return a name
* */

const studentArray = [];

function randomNumberInRange (top, bottom){
return Math.floor( Math.random() * ( 1 + top - bottom ) ) + bottom;
}

console.log(randomNumberInRange(14, 0));
function generateRandomName() {
const index = randomNumberInRange(studentArray.length -1, 0);
return studentArray[index];
}
79 changes: 78 additions & 1 deletion 01week/javascripting/introduction.js
Original file line number Diff line number Diff line change
@@ -1 +1,78 @@
console.log('hello');
'use strict';

// Write a JavaScript program to display the current day and time.

function currentDateTime(){
console.log(new Date());

Choose a reason for hiding this comment

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

The logic is right, however the function call is a little off. Your function should return the new date, and you should call the function in a console.log to display.
function currentDateTime(){ return new Date(); } console.log(currentDateTime());

}
currentDateTime();


// Write a JavaScript program to convert a number to a string.

function numberToString(num){
console.log(num.toString());

Choose a reason for hiding this comment

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

The logic is right, however the function call is a little off. Your function should return the new date, and you should call the function in a console.log to display.

}
numberToString(10);



// Write a JavaScript program to convert a string to the number.

function stringToNumber(number){
console.log(parseInt(number));

Choose a reason for hiding this comment

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

The logic is right, however the function call is a little off. Your function should return the new date, and you should call the function in a console.log to display.

}
stringToNumber(224);


// Write a JavaScript program that takes in different datatypes and prints out whether they are a:
// Boolean
// Null
// Undefined
// Number
// NaN
// String

function ReturnType(someData){
console.log(typeof someData);

Choose a reason for hiding this comment

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

The logic is right, however the function call is a little off. Your function should return the new date, and you should call the function in a console.log to display.

}
ReturnType('Hello');
ReturnType(10);
ReturnType();
ReturnType(true);
ReturnType(0/0);


// Write a JavaScript program that adds 2 numbers together.

function addingStuff(dig1, dig2){
console.log( dig1 + dig2 );

Choose a reason for hiding this comment

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

The logic is right, however the function call is a little off. Your function should return the new date, and you should call the function in a console.log to display.

}
addingStuff(4, 7);

// Write a JavaScript program that runs only when 2 things are true.
function trueTings (x, y){
if(x === true && y === true) {

Choose a reason for hiding this comment

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

This function as is evaluates if x & y are equal to the boolean "true". So to get it to run you would have to pass in the literal boolean "true". I need the function to evaluate if x & y evaluate to true. if(x&y){...}

console.log("It's True!");
}

Choose a reason for hiding this comment

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

The logic is right, however the function call is a little off. Your function should return the new date, and you should call the function in a console.log to display.

}
trueTings(true,true);


// Write a JavaScript program that runs when 1 of 2 things are true.

function oneTingTrue (z, p) {
if (p || z === true) {

Choose a reason for hiding this comment

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

This function as is evaluates if x is equal to the boolean "true". So to get it to run you would have to pass in the literal boolean "true". I need the function to evaluate if x or p evaluates to true.

console.log("There can only be one");
}

Choose a reason for hiding this comment

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

The logic is right, however the function call is a little off. Your function should return the new date, and you should call the function in a console.log to display.

}
oneTingTrue(true, true);

// Write a JavaScript program that runs when both things are not true.

function noTrueTings (w, r) {
if (w != 2 && r != 13){
console.log("Yeah right! Neither are true");

Choose a reason for hiding this comment

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

The logic is right, however the function call is a little off. Your function should return the new date, and you should call the function in a console.log to display.

}
}
noTrueTings(true, true);