lundi 19 octobre 2020

JavaScript Lexicographic order string comparison with FOR loop (no methods)

here the ex:

3.3 Depending on the lexicographic order of the strings, print:

  • The driver's name goes first.
  • Yo, the navigator goes first definitely.
  • What?! You both have the same name?
    const hacker1 = 'Pedro';
    const hacker2 = 'Davide'; 

How could I do it without using methods (Since I am learning I should only use split() or charAt() if necessary No other methods allowed?

I think I have to use conditional but I don't know how to loop over each character while comparing it using FOR

Aucun commentaire:

Enregistrer un commentaire