Skip to content

resolucion hasta el ejercicio 5 #564

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

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
2 changes: 1 addition & 1 deletion 01_helloWorld/helloWorld.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const helloWorld = function() {
return ''
return 'Hello, World!';
};

module.exports = helloWorld;
2 changes: 1 addition & 1 deletion 02_addNumbers/addNumbers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function addNumbers() {

let result;

result = "a" + "b"; // <------ EDIT THIS LINE
result = a + b; // <------ EDIT THIS LINE

return result;
}
Expand Down
2 changes: 1 addition & 1 deletion 03_numberChecker/numberChecker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function numberChecker(number) {
if (number === 6) {
if (number >= 10) {
return true;
} else {
return false;
Expand Down
10 changes: 5 additions & 5 deletions 04_mathEquations/mathEquations.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const a = 1 - 1 // Freebie!!! This is the answer to "one minus one"
const b = "one plus eight"
const c = "22 times three"
const d = "the *remainder* of 5/4"
const e = "the variable 'b' minus 17"
const f = "the sum of the previous five variables"
const b = 1 + 8
const c = 22*3
const d = 5%4
const e = b -17
const f = a+b+c+d+e

// Do not edit below this line
module.exports = {a, b, c, d, e, f}
10 changes: 7 additions & 3 deletions 05_joinStrings/joinStrings.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@
*/

// Add your code right below, good luck!
let firstName = "Carlos";
let lastName = "Stevenson";
let thisYear = 1965;
let birthYear = 1947;
let fullName = firstName + " " + lastName;
let age = thisYear - birthYear;




let greeting = "Hello! My name is " + fullName + " and I am " + age + " years old.";

// Do not change this
module.exports = {
Expand Down
12 changes: 6 additions & 6 deletions 05_joinStrings/joinStrings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ describe('step 2', () => {
test('firstName is Carlos', () => {
expect(values.firstName).toEqual('Carlos');
});
test.skip('lastName is Stevenson', () => {
test('lastName is Stevenson', () => {
expect(values.lastName).toEqual('Stevenson');
});
test.skip('thisYear is 1965', () => {
test('thisYear is 1965', () => {
expect(values.thisYear).toEqual(1965);
});
test.skip('birthYear is 1947', () => {
test('birthYear is 1947', () => {
expect(values.birthYear).toEqual(1947);
});
test.skip('greeting is properly output', () => {
test('greeting is properly output', () => {
expect(values.greeting).toEqual('Hello! My name is Carlos Stevenson and I am 18 years old.');
});
});

describe('step 3', () => {
test.skip('fullName is Carlos Stevenson', () => {
test('fullName is Carlos Stevenson', () => {
expect(values.fullName).toEqual('Carlos Stevenson');
});
test.skip('age is 18', () => {
test('age is 18', () => {
expect(values.age).toEqual(18);
});
});
12 changes: 9 additions & 3 deletions 06_repeatString/repeatString.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
const repeatString = function() {

};
function repeatString(string, num) {
if (num < 0) return 'ERROR';
if (num === 0) return '';
let repeatedString = '';
for (let i = 0; i < num; i++) {
repeatedString += string;
}
return repeatedString;
}

// Do not edit below this line
module.exports = repeatString;
14 changes: 7 additions & 7 deletions 06_repeatString/repeatString.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ describe('repeatString', () => {
test('repeats the string', () => {
expect(repeatString('hey', 3)).toEqual('heyheyhey');
});
test.skip('repeats the string many times', () => {
test('repeats the string many times', () => {
expect(repeatString('hello', 10)).toEqual('hellohellohellohellohellohellohellohellohellohello');
});
test.skip('repeats the string 1 time', () => {
test('repeats the string 1 time', () => {
expect(repeatString('hi', 1)).toEqual('hi');
});
test.skip('repeats the string 0 times', () => {
test('repeats the string 0 times', () => {
expect(repeatString('bye', 0)).toEqual('');
});
test.skip('does not use the built-in String repeat method', () => {
test('does not use the built-in String repeat method', () => {
/* Even though there is a built-in String repeat method,
in this exercise specifically, we want you to practise using loops */
jest.spyOn(String.prototype, 'repeat').mockName('Built-in String repeat method');
repeatString("don't use the built-in repeat method!", 1);
expect(String.prototype.repeat).not.toHaveBeenCalled();
});
test.skip('returns ERROR with negative numbers', () => {
test('returns ERROR with negative numbers', () => {
expect(repeatString('goodbye', -1)).toEqual('ERROR');
});
test.skip('repeats the string a random amount of times', function () {
test('repeats the string a random amount of times', function () {
/* The number is generated by using Math.random to get a value from between
0 to 1, when this is multiplied by 1000 and rounded down with Math.floor it
equals a number between 0 to 999 (this number will change everytime you run
Expand All @@ -36,7 +36,7 @@ describe('repeatString', () => {
const number = Math.floor(Math.random() * 1000);
expect(repeatString('hey', number)).toBe('hey'.repeat(number));
});
test.skip('works with blank strings', () => {
test('works with blank strings', () => {
expect(repeatString('', 10)).toEqual('');
});
});
9 changes: 7 additions & 2 deletions 07_reverseString/reverseString.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
const reverseString = function() {

const reverseString = function(string) {
// Your code here
let reversed = '';
for (let i = string.length - 1; i >= 0; i--) {
reversed += string[i];
}
return reversed;
};

// Do not edit below this line
Expand Down
6 changes: 3 additions & 3 deletions 07_reverseString/reverseString.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ describe('reverseString', () => {
expect(reverseString('hello')).toEqual('olleh');
});

test.skip('reverses multiple words', () => {
test('reverses multiple words', () => {
expect(reverseString('hello there')).toEqual('ereht olleh');
});

test.skip('works with numbers and punctuation', () => {
test('works with numbers and punctuation', () => {
expect(reverseString('123! abc! Hello, Odinite.')).toEqual(
'.etinidO ,olleH !cba !321'
);
});
test.skip('works with blank strings', () => {
test('works with blank strings', () => {
expect(reverseString('')).toEqual('');
});
});
Loading