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
21 changes: 21 additions & 0 deletions 01week/javascripting/chance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';
/**Pick a random student from this class
*Store names in a variable-array
*generate a random number, less than amount in class
*apply index to array
*from that array, pick a random name
*return a name
**/

const studentArray = ['dude','person','thing'];

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


function generateRandomName(){
const index = randomNumberInRange(studentArray.length-1, 0);
return studentArray[index];
}
console.log(generateRandomName());
61 changes: 61 additions & 0 deletions 01week/javascripting/data-types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

function returnDate(){
const date=new Date();
return date;}

console.log(returnDate())


function NtoS() {
const num = 7;
const n = num.toString();
return (n);
}

console.log(NtoS());

function stuff(){
const s = parseInt('77');
return (s);
}
console.log(stuff());


function add(){
const sum = 3+4;
return (sum);
}
console.log (add());



function twotrue(){
const x=5
const y=5
if (x===y){
return('true');
}

}
console.log(twotrue());

function onetrue(){
const x2=5
const y2='5'
if (x2===5 && y2!==5){
return('1true');
}
}
console.log(onetrue());

console.log(typeof x);
console.log(typeof y2);

function allfalse(){
const x3=5
const y3='5'
if (x3!=='5' && y3!==5){
return('false');
}
}
console.log(allfalse());
24 changes: 22 additions & 2 deletions 01week/rockPaperScissors.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,31 @@ const rl = readline.createInterface({
});


function rockPaperScissors(hand1, hand2) {

// Write code here

// Write code here
function rockPaperScissors(hand1, hand2){
if (hand1 === 'rock' && hand2 === 'rock') {
return "It's a tie!";

Choose a reason for hiding this comment

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

The logic seems sound but you are repeating yourself a lot, think of a way reduce this

}else if (hand1 === 'paper' && hand2 === 'paper') {
return "It's a tie!";
}else if (hand1 === 'scissors' && hand2 === 'scissors') {
return "It's a tie!";
}else if (hand1==='rock' && hand2==='paper') {
return "Hand two wins!";
}else if (hand1==='rock' && hand2 === 'scissors') {
return "Hand one wins!";
}else if (hand1 === 'paper' && hand2 === 'scissors') {
return "Hand two wins!";
}else if (hand1 === 'paper' && hand2 === 'rock') {
return "Hand one wins!";
}else if (hand1 === 'scissors' && hand2 === 'paper') {
return "Hand one wins!";
}else if (hand1 === 'scissors' && hand2 === 'rock') {
return "Hand 2 wins!";
}
}
console.log(rockPaperScissors());

function getPrompt() {
rl.question('hand1: ', (answer1) => {
Expand Down