Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Take a Ten Minute Walk js

function isValidWalk(walk) {
  var dx = 0
  var dy = 0
  var dt = walk.length

  for (var i = 0; i < walk.length; i++) {
    switch (walk[i]) {
      case 'n': dy--; break
      case 's': dy++; break
      case 'w': dx--; break
      case 'e': dx++; break
    }
  }

  return dt === 10 && dx === 0 && dy === 0
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: find max days of month js 
Javascript :: convert result of .innerHTML to number on javascript 
Javascript :: classname did not match server next js styled components 
Javascript :: javascript sort by date descending 
Javascript :: picker change event react native 
Javascript :: javascript onload complete 
Javascript :: multiple import react js 
Javascript :: localstorage clear item 
Javascript :: get all keys in json object 
Javascript :: generate combinations of values from multiple array javascript 
Javascript :: java gson string to json 
Javascript :: inner html jquery 
Javascript :: add id attribute to jQuery steps 
Javascript :: reverse int js 
Javascript :: scroll to div js 
Javascript :: react conditionally disable button 
Javascript :: days difference in moment js 
Javascript :: bootstrap disable button after click 
Javascript :: react native strike through text 
Javascript :: syntax for srcset in react 
Javascript :: nodejs how to send html 
Javascript :: average function for javascript 
Javascript :: how to get single element from nested array mongoose 
Javascript :: how to change color on js 
Javascript :: javascript log html element as dom object 
Javascript :: localdatetime json 
Javascript :: Close popup window 
Javascript :: react public pic 
Javascript :: url regular expression 
Javascript :: Error: Unable to resolve module ./index from 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =