The browser storage localStorage is not available. Either your browser does not support it or you have disabled it or the maximum memory size is exceeded. Without localStorage your solutions will not be stored.

String: substr()

The substr method extracts a substring from a string:
var see = 'see and stop'.substr(0, 3);
var and = 'see and stop'.substr(4, 3);
var stop = 'see and stop'.substr(8);
The first parameter specifies the position at which to start extracting. The second parameter specifies the number of characters to extract. If the second parameter is not set, all the characters from start position to the end of the string are extracted.


Write a function firstWord, taking a string and returning the first word in that string. The first word are all characters up to the first space. firstWord('see and stop') should return 'see'.
var firstWord = function(s) {
// Determine with indexOf
// the position of the
// first space. Then use
// the substr method.
var firstWord = function(s) {
  var firstBlank = s.indexOf(' ');
  return s.substr(0, firstBlank);