-
Notifications
You must be signed in to change notification settings - Fork 47
LISFT0123 Pedro Leal - First Lab #13
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
base: main
Are you sure you want to change the base?
Conversation
lzaquine
left a comment
There was a problem hiding this 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"; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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){ |
There was a problem hiding this comment.
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++) { |
There was a problem hiding this comment.
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--){ |
There was a problem hiding this comment.
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);
No description provided.