From aa86ec8cfeb17b6f162c523ba9b3262458ff9568 Mon Sep 17 00:00:00 2001 From: MARIA Date: Tue, 9 Aug 2022 21:35:00 +0200 Subject: [PATCH 1/3] first iteration --- js/index.html | 15 +++++++++++++++ js/index.js | 5 ++++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 js/index.html diff --git a/js/index.html b/js/index.html new file mode 100644 index 000000000..e4d4170ce --- /dev/null +++ b/js/index.html @@ -0,0 +1,15 @@ + + + + + JAVASCRIPT LAB 1 + + + + + +

Lab 1 JAVASCRIPT

+ + + + diff --git a/js/index.js b/js/index.js index 59e4af7fb..0618ae041 100644 --- a/js/index.js +++ b/js/index.js @@ -1,5 +1,8 @@ // Iteration 1: Names and Input -// +let hacker1 = "Maria"; +let hacker2 = "Marcos"; + console.log("The driver's name is "+"" + hacker1); + console.log("The navigator's name is "+"" + hacker2); // Iteration 2: Conditionals From 711d8d7a3d8850be998fe0f561c5c311db82ff8b Mon Sep 17 00:00:00 2001 From: MARIA Date: Thu, 11 Aug 2022 21:14:42 +0200 Subject: [PATCH 2/3] iteration 2-3 --- js/index.js | 48 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/js/index.js b/js/index.js index 0618ae041..af52668ce 100644 --- a/js/index.js +++ b/js/index.js @@ -1,9 +1,51 @@ // Iteration 1: Names and Input -let hacker1 = "Maria"; -let hacker2 = "Marcos"; + + + //driver + let hacker1 = "Maria"; + //navigator + let hacker2 = "Marcos"; + let newString= ""; + let totalCharacter = 0; console.log("The driver's name is "+"" + hacker1); console.log("The navigator's name is "+"" + hacker2); -// Iteration 2: Conditionals +//Iteration 2: Conditionals + if(hacker1.length > hacker2.length) { + console.log("The driver has the longest name, it has" + " " + hacker1.length + " characters."); + }else if(hacker1.length < hacker2.length){ + console.log("It seems that the navigator has the longest name, it has" + " " + hacker2.length + " characters."); + }else{ + console.log("Wow, you both have equally long names, XX characters!"); +} // Iteration 3: Loops +/*3.1 Print all the characters of the driver's name, +separated by a space and in capitals i.e. "J O H N"*/ + + let textName = "maria"; + let newTextName = ""; + + for(let i = 0; i < textName.length; i++) { + newTextName += textName [i] + (" "); + console.log(newTextName.toUpperCase()); + + } +//3.2 Print all the characters of the navigator's name, in reverse order. i.e. "nhoJ" + + let nameText = "marcos"; + let nameReverse = ""; + let nameLenght = nameText.length -1; + + for(let i = nameLenght; i >= nameLenght; i--) { + nameReverse += nameText[i]; + console.log(nameReverse.toUpperCase()); + } + //3.3 Depending on the lexicographic order of the strings, print: + if(hacker1 > hacker2) { + console.log("The driver's name goes first."); + }else if(hacker1 < hacker2){ + console.log("Yo, the navigator goes first definitely"); + }else{ + console.log("What?! You both have the same name?"); +} From 991377d24f61d41b5d176c2172a6ca9093a69570 Mon Sep 17 00:00:00 2001 From: MARIA Date: Fri, 12 Aug 2022 08:21:52 +0200 Subject: [PATCH 3/3] corregido error --- js/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/index.js b/js/index.js index af52668ce..cd8dcf9db 100644 --- a/js/index.js +++ b/js/index.js @@ -37,7 +37,7 @@ separated by a space and in capitals i.e. "J O H N"*/ let nameReverse = ""; let nameLenght = nameText.length -1; - for(let i = nameLenght; i >= nameLenght; i--) { + for(let i = nameLenght; i >= 0; i--) { nameReverse += nameText[i]; console.log(nameReverse.toUpperCase()); }