Skip to content

Instantly share code, notes, and snippets.

View carlmlane's full-sized avatar
🌱
here we grow

Carl M. Lane carlmlane

🌱
here we grow
View GitHub Profile
1. Create a function with a loop that prints out only the odd positioned elements of an array that it takes in.
var myArray = ["Carl", "Addison", "Alex", "Marshall", "Nancy", "Tryana", "Peter"]
// Iterates through array and prints out only oddly-positioned numbers
for (i=0; i<myArray.length; i++) {
if ( i % 2 == 1) {
console.log(myArray[i]);
}
2. Create a function with a loop that prints out only the even numbers of an array that consists of only numbers.
@carlmlane
carlmlane / happy_birthday.py
Created August 6, 2015 17:30
Happy Birthday Peter
#!/usr/bin/python
import curses
import random
stdscr = curses.initscr()
curses.noecho()
curses.cbreak()
stdscr.keypad(1)
curses.halfdelay(1)