Skip to content
Open
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
47 changes: 42 additions & 5 deletions my-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
* For an example, you get the first for free!
*/

const greeting = (Carni) => {
return `Hello, ${Carni}!`;
}

/**
* Write a function called `greeting` that returns the string `Hello, <name>!`
Expand All @@ -21,46 +24,80 @@ const greeting = (name) => {
/**
* Write a function called `add` that returns the sum of two numbers
*/
const add = function(x,y) {
return x + y;
};


/**
* Write a function called `subtract` that returns the difference between two numbers
*/
const subtract = function(x,y) {
return x - y;
};


/**
* Write a function called `min` that returns the smaller of two numbers
*/


const min = function(x,y) {
return Math.min(x,y);
};
/**
* Write a function called `max` that returns the larger of two numbers
*/

const max = function(x,y) {
return Math.max(x,y);
};
/**
* Write a function called `isEven` that takes a single value and
* returns `true` if it is even and `false` if it is odd
*/
const isEven = function(x) {
return x % 2 == 0;
};
/**
*WHY IS THIS SO HARD?!?!?!?
*/


/**
* Write a function called `isOdd` that takes a single value and
* returns `false` if it is even and `true` if it is odd
*/

const isOdd = function(y) {
return x % 2 == 1;

/**
* Write a function called `factorial` that takes a single integer and
* returns the product of the integer and all the integers below it
*/

/*
*FORGET IT! I DID THE REST! IF I KEEP TRYING TO FIGURE
*THIS OUT, I'LL BE SPEAKING IN NUMBERS, LETTERS, AND
*SPECIAL CHARACTERS BY MORNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*IRL BASH COMMAND!!! I'M OUT!!!
*/

/**
* Write a function called `oddFactorial` that takes a single integer and
* returns the product of the integer and all the integers below it, but
* only if they are odd. If the starting number is even, don't include it.
*/

var size = 8;

var board = "";

for (var y = 0; y < size; y++) {
for (var x = 0; x < size; x++) {
if ((x + y) % 2 == 0)
board += " ";
else
board += "#";
}
board += "\n";
}

/**
* Write a function that solves the Chessboard exercise from chapter two,
Expand Down