Skip to content

WD-FT-APRIL25-ES María Jiménez (lab-js-data-types) #590

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 1 commit into
base: master
Choose a base branch
from
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
36 changes: 31 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ const s4 = "bread";
const s5 = "and";

// Concatenate the string variables into one new string

let tongueTwister = `"${s1} ${s2} ${s3} ${s4} ${s5} ${s3} ${s2} ${s1} ${s4}"`;

// Print out the concatenated string

console.log (tongueTwister);



Expand All @@ -22,11 +22,14 @@ const part1 = "java";
const part2 = "script";

// Convert the last letter of part1 and part2 to uppercase and concatenate the strings
let part1CamelTail = part1.slice(0, part1.length - 1) + part1[part1.length - 1].toUpperCase();
let part2CamelTail = part2.slice(0, part2.length - 1) + part2[part2.length - 1].toUpperCase();

let result = `"${part1CamelTail}${part2CamelTail}"`;

// Print the cameLtaiL-formatted string


console.log (result);


/*******************************************
Expand All @@ -36,9 +39,12 @@ const billTotal = 84;

// Calculate the tip (15% of the bill total)

let tipAmount = billTotal * 0.15;


// Print out the tipAmount

console.log ("The amount you have to leave as a tip is: " + tipAmount);



Expand All @@ -47,10 +53,11 @@ const billTotal = 84;
*******************************************/

// Generate a random integer between 1 and 10 (inclusive)

let randomNumber = Math.floor(Math.random() * 10) + 1;

// Print the generated random number

console.log (randomNumber);


/*******************************************
Expand All @@ -62,15 +69,34 @@ const b = false;

// Try and guess the output of the below expressions first and write your answers down:
const expression1 = a && b;
//Expression1 es falsa, porque && indica que ambas tienen que ser verdaderas para devolver true.
console.log ("Expresión 1: " +expression1);

const expression2 = a || b;
//Expression2 es verdadera, porque || indica que con que alguna de las dos sea verdadera
// (en este caso a es verdadera), devuelve true.
console.log("Expresión 2: " + expression2);

const expression3 = !a && b;
//Expression3 es falsa, porque ambos valores son falsos y
// para que una expresión con &&, ambas tienen que ser verdaderas.
console.log("Expresión 3: " + expression3);

const expression4 = !(a && b);
//Expression4 es verdadera, porque (a && b) es igual a false,
// pero ! indica que esa expresión es lo contrario, es decir, verdadera.
console.log("Expresión 4: " + expression4);

const expression5 = !a || !b;
//Expression5 es verdadera, porque !a = false, pero !b = true,
// por lo tanto, al menos una es verdadera y devuelve true.
console.log("Expresión 5: " + expression5);

const expression6 = !(a || b);
//Expression6 es falsa, porque (a || b) = true pero el
//* ! al inicio invierte el resultado y la convierte en falsa.
console.log("Expresión 6: " + expression6);

const expression7 = a && a;
const expression7 = a && a;
//Expression7 es verdadera porque a es true, por tanto, true && true = true.
console.log("Expresión 7: " + expression7);