This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* VERY simple web server in Node with limited/no error trapping | |
*/ | |
var http = require( 'http' ); | |
var fs = require( 'fs' ); | |
const PORT = 8080; | |
function handleRequest( req, res ){ | |
var url = '/index.html'; // default path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h2>Count letters in text</h2> | |
<p>Enter some text and watch the script count each letter in it, and return as a sorted list, most common first.</p> | |
<form> | |
<textarea style="width:90%;height:400px;" id="para"></textarea> | |
</form> | |
<ul id="alpha"></ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h2>Convert camel case to snake case</h2> | |
<p>Enter a camel case string.</p> | |
<form> | |
<input type="text" id="camel" value="camelCaseWord" /> | |
<button id="butn" type="button">Go!</button> | |
</form> | |
<div id="output"></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hangman | |
attr_reader :answer # creates getter method so class property is not accessed directly as data | |
def initialize() | |
@answer = get_answer # set the value of the class property | |
end | |
def get_answer() | |
puts "Enter Answer:" # prints a prompt to the screen | |
gets.chomp.upcase # gets the input from user and converts it to uppercase - convert later to a method to validate format (/[a-zA-Z ]{3,30}/) | |
end | |
end |