Longest String

Script to return the longest string of two

by Hannah McFarlane

HTML

<script src="https://getfirebug.com/firebug-lite-debug.js"></script>

JavaScript

var stringTest = function(x, y) {
  if (x.length === y.length) {
    console.log("Both strings are the same length!")
  } else {
    console.log("The longest string is: ");
    if (x.length > y.length) {
      console.log("#1: " + x);
    } else {
      console.log("#2: " + y);
    }
  }
}

var string1 = prompt("Enter some text:");
var string2 = prompt("Enter some more text:");

stringTest(string1, string2);