Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

anything #265

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 26 additions & 10 deletions src/01-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
* alwaysTrue();
* //> true
*/
function alwaysTrue() {}
function alwaysTrue() {
return true;
}

/**
* greet()
Expand All @@ -24,7 +26,9 @@ function alwaysTrue() {}
* greet("Ian");
* //> "Hello, Ian."
*/
function greet() {}
function greet(name) {
return `Hello, ${name}.`
}

/**
* add()
Expand All @@ -39,7 +43,9 @@ function greet() {}
* add(10, 20);
* //> 30
*/
function add() {}
function add(a, b) {
return a + b
}

/**
* multiply()
Expand All @@ -54,7 +60,9 @@ function add() {}
* multiply(2, 5);
* //> 10
*/
function multiply() {}
function multiply(a,b) {
return a * b
}

/**
* average()
Expand All @@ -74,7 +82,11 @@ function multiply() {}
* average(10, 6);
* //> 8 // 10 + 6 = 16; 16/2 = 8;
*/
function average() {}
function average(a,b) {
let sum = a + b

return sum / 2
}

/**
* averageThree()
Expand All @@ -93,7 +105,9 @@ function average() {}
* averageThree(10, 11, 19);
* //> 10 // 10 + 11 + 19 = 30; 30 / 3 = 10;
*/
function averageThree() {}
function averageThree(a,b,c) {
return (a + b + c)/3
}

/**
* compareTypes()
Expand All @@ -112,7 +126,7 @@ function averageThree() {}
* compareTypes("left", 10);
* //> false
*/
function compareTypes() {}
function compareTypes(a,b) {}

/**
* flipSign()
Expand All @@ -131,7 +145,8 @@ function compareTypes() {}
* flipSign(50);
* //> -50
*/
function flipSign() {}
function flipSign(a) {
}

/**
* joinStringsWithSpaces()
Expand All @@ -151,7 +166,8 @@ function flipSign() {}
* joinStringsWithSpaces("left", "right", "up", "down", "away");
* //> "left right up down away"
*/
function joinStringsWithSpaces() {}
function joinStringsWithSpaces(a,b,c,d,e) {
}

/**
* getFirstAndLastCharacter()
Expand All @@ -168,7 +184,7 @@ function joinStringsWithSpaces() {}
* getFirstAndLastCharacter("upwards");
* //> "us"
*/
function getFirstAndLastCharacter() {}
function getFirstAndLastCharacter(a) {}

// Do not change the code below.
module.exports = {
Expand Down
28 changes: 21 additions & 7 deletions src/02-data-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
* getLengthOfString("down");
* //> 4
*/
function getLengthOfString(str) {}
function getLengthOfString(str) {
return str.length
}

/**
* convertToNumber()
Expand All @@ -22,7 +24,9 @@ function getLengthOfString(str) {}
* convertToNumber("111");
* //> 111
*/
function convertToNumber(val) {}
function convertToNumber(val) {
return Number(val)
}

/**
* convertToString()
Expand All @@ -36,7 +40,9 @@ function convertToNumber(val) {}
* convertToString(99);
* //> "99"
*/
function convertToString(val) {}
function convertToString(val) {
return val.toString()
}

/**
* convertToShoutingText()
Expand All @@ -49,7 +55,9 @@ function convertToString(val) {}
* convertToShoutingText("Hello There");
* //> "HELLO THERE"
*/
function convertToShoutingText(text) {}
function convertToShoutingText(text) {
return text.toUpperCase();
}

/**
* convertToWhisperText()
Expand All @@ -62,7 +70,9 @@ function convertToShoutingText(text) {}
* convertToWhisperText("Hello There");
* //> "hello there"
*/
function convertToWhisperText(text) {}
function convertToWhisperText(text) {
return text.toLowerCase();
}

/**
* checkIfCharacterIsInString()
Expand All @@ -79,7 +89,9 @@ function convertToWhisperText(text) {}
* checkIfCharacterIsInString("hello there", "a");
* //> false
*/
function checkIfCharacterIsInString(text, character) {}
function checkIfCharacterIsInString(text, character) {
return text.includes(character)
}

/**
* isEven()
Expand Down Expand Up @@ -127,7 +139,9 @@ function isOdd(num) {}
* isTruthy(null);
* //> false
*/
function isTruthy(val) {}
function isTruthy(val) {

}

/**
* isFalsy()
Expand Down
63 changes: 56 additions & 7 deletions src/03-control-flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@
* isEqual(10, "10");
* //> false
*/
function isEqual(a, b) {}
function isEqual(a, b) {
if(a === b){
return true
} else {
return false
}
}

/**
* findLarger()
Expand All @@ -28,7 +34,13 @@ function isEqual(a, b) {}
* findLarger(19, 7);
* //> 19
*/
function findLarger(a, b) {}
function findLarger(a, b) {
if(a > b){
return a
} else if (b > a) {
return b
}
}

/**
* findLargerOrTie()
Expand All @@ -45,7 +57,15 @@ function findLarger(a, b) {}
* findLargerOrTie(0, 0);
* //> "tie"
*/
function findLargerOrTie(a, b) {}
function findLargerOrTie(a, b) {
if(a > b){
return a
} else if (b > a){
return b
}else if (a === b){
return "tie"
}
}

/**
* positiveNegativeOrZero()
Expand All @@ -65,7 +85,17 @@ function findLargerOrTie(a, b) {}
* positiveNegativeOrZero(1);
* //> "Positive"
*/
function positiveNegativeOrZero(a) {}
function positiveNegativeOrZero(a) {
if(a === 0){
return "Zero"
} else if (a >= 1){
return "Positive"
} else if (a <= -1){
return "Negative"
} else {
return NaN
}
}

/**
* aroundTheWorldGreeting()
Expand All @@ -86,7 +116,17 @@ function positiveNegativeOrZero(a) {}
* aroundTheWorldGreeting();
* //> "Hello World"
*/
function aroundTheWorldGreeting(language) {}
function aroundTheWorldGreeting(language) {
if(language === 'english'){
return 'Hello World'
} else if(language === 'spanish'){
return 'Hola Mundo'
}else if(language === 'german'){
return 'Hallo Welt'
} else {
return 'Hello World'
}
}

/**
* aroundTheWorldGreetingWithSwitch()
Expand Down Expand Up @@ -163,7 +203,13 @@ function animalCounts(animal, numberOfAnimals) {}
* evenOrOdd(48);
* //> "Even"
*/
function evenOrOdd(a) {}
function evenOrOdd(a) {
if(a % 2 === 0){
return "Even"
} else {
return "Odd"
}
}

/**
* evenOrOddWithTernary()
Expand All @@ -179,7 +225,10 @@ function evenOrOdd(a) {}
* evenOrOddWithTernary(8);
* //> "Even"
*/
function evenOrOddWithTernary(a) {}
function evenOrOddWithTernary(a) {
return a % 2 === 0 ? "Even":"Odd"

}

// Do not change any code below this line.
module.exports = {
Expand Down
24 changes: 19 additions & 5 deletions src/04-arrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ function createEmptyArray() {}
* createArrayWithTwoElements(true, false);
* //> [ true, false ]
*/
function createArrayWithTwoElements(a, b) {}
function createArrayWithTwoElements(a, b) {
let array = [];
array.push(a)
array.push(b)
return array

}

/**
* getArrayLength()
Expand All @@ -37,7 +43,9 @@ function createArrayWithTwoElements(a, b) {}
* getArrayLength([ 10, 20, 30 ]);
* //> 3
*/
function getArrayLength(array) {}
function getArrayLength(array) {

}

/**
* getFirstElementOfArray()
Expand Down Expand Up @@ -65,7 +73,9 @@ function getFirstElementOfArray(array) {}
* getLastElementOfArray([ null, undefined ]);
* //> undefined
*/
function getLastElementOfArray(array) {}
function getLastElementOfArray(array) {
return array[array.length-1]
}

/**
* addElementToEndOfArray()
Expand All @@ -79,7 +89,10 @@ function getLastElementOfArray(array) {}
* addElementToEndOfArray([ 10 ], 9);
* //> [ 10, 9 ]
*/
function addElementToEndOfArray(array, element) {}
function addElementToEndOfArray(array, element) {
array.push(element)
return array
}

/**
* removeElementFromEndOfArray()
Expand Down Expand Up @@ -135,7 +148,8 @@ function removeElementFromFrontOfArray(array) {}
* getMiddleElement([ 10, null, "30" ]);
* //> null
*/
function getMiddleElement(array) {}
function getMiddleElement(array) {
}

// Do not change any code below this line.
module.exports = {
Expand Down
Loading