Skip to content

Conversation

@PeterLoyal
Copy link

No description provided.

Copy link

@lzaquine lzaquine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job on the lab, Pedro! Check the comments I added for a better understanding

// Iteration 1: Names and Input
console.log("I`m ready");

let hacker1 = "The driver's name is Leal";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, instead of passing the variable as the whole string, you could've given just your name and console.log the string after, like:

const hacker1 = 'Leal';
 console.log(`The driver's name is ${hacker1}.`);
 const hacker2 = 'Duarte';
 console.log(`The navigator's name is ${hacker2}.`)


// Iteration 2: Conditionals

let driverName = hacker1.slice(21);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So here you wouldn't need to use slice();

let numOfCharNavigator = navigatorName.length;


if( driverName.length > navigatorName.length){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job on creating the variables numOfCharDriver and numOfCharNavigator . Here on the if statement, you could've used them like:

if( numOfCharDriver > numOfCharNavigator)

// Iteration 3: Loops

//3.1
for (let i = 0; i < driverName.length; i++) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, the idea was to print all the characters of the driver's name, separated by a space and in capitals i.e. "L E A L".

A good solution would be:

let withSpace = '';
for (let i = 0; i < hacker1.length; i++) {
     withSpace += hacker1.[i] + ' ';
 }
console.log(withSpace.toUpperCase());


//3.2

for(let i = navigatorName.length -1 ; i >= 0; i--){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, the idea was to print all the characters of the navigator's name in reverse order. i.e. "etrauD"

One way of doing that:

let reverseName = '';
for (let i = hacker2.length - 1; i >= 0; i--) {
  reverseName += hacker2[i];
}
console.log(reverseName);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants