Skip to content

Instantly share code, notes, and snippets.

@cdvillard
Forked from anonymous/index.html
Created March 22, 2016 15:02
Show Gist options
  • Save cdvillard/fdfc25486aac318268ac to your computer and use it in GitHub Desktop.
Save cdvillard/fdfc25486aac318268ac to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/ranayug
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
var array=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
function fizzBuzz() {
for(var i = array[0]; i <= array.length; i++) {
if (i % 2 === 0 && i % 3 === 0){
console.log("FizzBuzz");
} else if (i % 3 === 0) {
console.log("Buzz");
} else if (i % 2 === 0) {
console.log("Fizz");
} else {
console.log(i);
}
}
}
fizzBuzz();
//Variables
//JS: var x = 10;
//PowerShell: [int]$x = 10;
//Python: x = 10;
//C: int x = 10;
//Collections
//JS: var array = [1, 2, 3, 4, 5, 6];
//PowerShell: $list = 1,2,3,4,5,6;
//PowerShell uses lists instead of arrays.
//Python: list = [1, 2, 3, 4, 5, 6]
//So does Python.
//C: int array[6] = {1, 2, 3, 4, 5, 6};
//Conditional Statements
/*
=== JS ===
var x = 10;
if (x < 10) {
console.log("Greater than 10");
} else if {
console.log("Less than 10");
} else {
console.log("Perfect 10");
}
=== PowerShell ===
$x = 10
if ($x -eq 10){
echo 'Greater than 10'
} elseif () {
echo 'Less than 10'
} else {
echo 'Perfect 10'
}
=== Python ===
x = 10
if x == 10
print("Greater than 10.")
elif x > 10
print("Less than 10.")
else
print("Perfect 10.")
=== C ===
int x = 10;
if (x == 10) {
printf("Greater than 10.\n");
} else if () {
printf("Less than 10.\n");
} else {
printf("Perfect 10.\n");
}
*/
//Looping
/*
=== JS ===
var arr = [1, 2, 3, 4, 5, 6];;
for(var i = 0; i < arr.length; i++) {
console.log("Item " + i + " in the array is " + arr[i]);
}
=== PowerShell ===
$list = 1,2,3,4,5,6
for($i = 1; $i -le $list.length; $i++) {
"Item " + $i + " in the array is " + $list[$i];
}
=== Python ===
list = [1, 2, 3, 4, 5, 6]
for item in list:
print("{} is an item in the list.".format(item))
=== C ===
int x[6] = {1, 2, 3, 4, 5, 6};
int i, j;
for (i = 0; i < 6; i++) {
printf("Item %d in the array is %d", i, x[i])
}
*/
//Modular Code
/*
=== JS ===
function helloworld() {
console.log("Hello World");
}
helloworld();
=== PowerShell ===
function helloworld {
echo "Hello World"
}
helloworld
=== Python ===
def helloworld():
print("Hello World")
helloworld()
=== C ===
#include<stdio.h>
int main()
{
printf("Hello World\n")
}
*/
</script>
<script id="jsbin-source-javascript" type="text/javascript">var array=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
function fizzBuzz() {
for(var i = array[0]; i <= array.length; i++) {
if (i % 2 === 0 && i % 3 === 0){
console.log("FizzBuzz");
} else if (i % 3 === 0) {
console.log("Buzz");
} else if (i % 2 === 0) {
console.log("Fizz");
} else {
console.log(i);
}
}
}
fizzBuzz();
//Variables
//JS: var x = 10;
//PowerShell: [int]$x = 10;
//Python: x = 10;
//C: int x = 10;
//Collections
//JS: var array = [1, 2, 3, 4, 5, 6];
//PowerShell: $list = 1,2,3,4,5,6;
//PowerShell uses lists instead of arrays.
//Python: list = [1, 2, 3, 4, 5, 6]
//So does Python.
//C: int array[6] = {1, 2, 3, 4, 5, 6};
//Conditional Statements
/*
=== JS ===
var x = 10;
if (x < 10) {
console.log("Greater than 10");
} else if {
console.log("Less than 10");
} else {
console.log("Perfect 10");
}
=== PowerShell ===
$x = 10
if ($x -eq 10){
echo 'Greater than 10'
} elseif () {
echo 'Less than 10'
} else {
echo 'Perfect 10'
}
=== Python ===
x = 10
if x == 10
print("Greater than 10.")
elif x > 10
print("Less than 10.")
else
print("Perfect 10.")
=== C ===
int x = 10;
if (x == 10) {
printf("Greater than 10.\n");
} else if () {
printf("Less than 10.\n");
} else {
printf("Perfect 10.\n");
}
*/
//Looping
/*
=== JS ===
var arr = [1, 2, 3, 4, 5, 6];;
for(var i = 0; i < arr.length; i++) {
console.log("Item " + i + " in the array is " + arr[i]);
}
=== PowerShell ===
$list = 1,2,3,4,5,6
for($i = 1; $i -le $list.length; $i++) {
"Item " + $i + " in the array is " + $list[$i];
}
=== Python ===
list = [1, 2, 3, 4, 5, 6]
for item in list:
print("{} is an item in the list.".format(item))
=== C ===
int x[6] = {1, 2, 3, 4, 5, 6};
int i, j;
for (i = 0; i < 6; i++) {
printf("Item %d in the array is %d", i, x[i])
}
*/
//Modular Code
/*
=== JS ===
function helloworld() {
console.log("Hello World");
}
helloworld();
=== PowerShell ===
function helloworld {
echo "Hello World"
}
helloworld
=== Python ===
def helloworld():
print("Hello World")
helloworld()
=== C ===
#include<stdio.h>
int main()
{
printf("Hello World\n")
}
*/
</script></body>
</html>
var array=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
function fizzBuzz() {
for(var i = array[0]; i <= array.length; i++) {
if (i % 2 === 0 && i % 3 === 0){
console.log("FizzBuzz");
} else if (i % 3 === 0) {
console.log("Buzz");
} else if (i % 2 === 0) {
console.log("Fizz");
} else {
console.log(i);
}
}
}
fizzBuzz();
//Variables
//JS: var x = 10;
//PowerShell: [int]$x = 10;
//Python: x = 10;
//C: int x = 10;
//Collections
//JS: var array = [1, 2, 3, 4, 5, 6];
//PowerShell: $list = 1,2,3,4,5,6;
//PowerShell uses lists instead of arrays.
//Python: list = [1, 2, 3, 4, 5, 6]
//So does Python.
//C: int array[6] = {1, 2, 3, 4, 5, 6};
//Conditional Statements
/*
=== JS ===
var x = 10;
if (x < 10) {
console.log("Greater than 10");
} else if {
console.log("Less than 10");
} else {
console.log("Perfect 10");
}
=== PowerShell ===
$x = 10
if ($x -eq 10){
echo 'Greater than 10'
} elseif () {
echo 'Less than 10'
} else {
echo 'Perfect 10'
}
=== Python ===
x = 10
if x == 10
print("Greater than 10.")
elif x > 10
print("Less than 10.")
else
print("Perfect 10.")
=== C ===
int x = 10;
if (x == 10) {
printf("Greater than 10.\n");
} else if () {
printf("Less than 10.\n");
} else {
printf("Perfect 10.\n");
}
*/
//Looping
/*
=== JS ===
var arr = [1, 2, 3, 4, 5, 6];;
for(var i = 0; i < arr.length; i++) {
console.log("Item " + i + " in the array is " + arr[i]);
}
=== PowerShell ===
$list = 1,2,3,4,5,6
for($i = 1; $i -le $list.length; $i++) {
"Item " + $i + " in the array is " + $list[$i];
}
=== Python ===
list = [1, 2, 3, 4, 5, 6]
for item in list:
print("{} is an item in the list.".format(item))
=== C ===
int x[6] = {1, 2, 3, 4, 5, 6};
int i, j;
for (i = 0; i < 6; i++) {
printf("Item %d in the array is %d", i, x[i])
}
*/
//Modular Code
/*
=== JS ===
function helloworld() {
console.log("Hello World");
}
helloworld();
=== PowerShell ===
function helloworld {
echo "Hello World"
}
helloworld
=== Python ===
def helloworld():
print("Hello World")
helloworld()
=== C ===
#include<stdio.h>
int main()
{
printf("Hello World\n")
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment