View remove_minimum.py
This file contains 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
# def remove_smallest(numbers): | |
# arr = numbers[:] | |
# if len(arr) > 0: | |
# arr.pop(arr.index(min(arr))) | |
# return arr | |
# else: | |
# return [] | |
def remove_smallest(numbers): | |
a = numbers[:] |
View find_next_square.py
This file contains 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
# import math | |
# def find_next_square(sq): | |
# # Return the next square if sq is a square, -1 otherwise | |
# if sq % math.sqrt(sq) == 0: | |
# sq_number = math.sqrt(sq) | |
# new_sq_sq = (sq_number + 1)**2 | |
# if new_sq_sq % math.sqrt(new_sq_sq) == 0: | |
# return new_sq_sq | |
# else: | |
# return -1 |
View uppercaseArray.js
This file contains 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
const changeToUpperCase = arr => { | |
const newArr = [] | |
for (const element of arr) { | |
newArr.push(element.toUpperCase()) | |
} | |
return newArr | |
} | |
const countries = ['Finland', 'Sweden', 'Norway', 'Denmark', 'Iceland'] | |
console.log(changeToUpperCase(countries)) |
View unlimitedSum.js
This file contains 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
// function declaration | |
| |
const sumAllNums = (...args) => { | |
let sum = 0 | |
for (const element of args) { | |
sum += element | |
} | |
return sum | |
} |
View maximumNumber.js
This file contains 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
let arr = [6, 89, 3, 45]; | |
let maximus = Math.max.apply(null, arr); | |
// Oh, even better | |
let maximus = Math.max(...arr) |
View vowelsConsonants.js
This file contains 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
function findVowelsConsonants(sentence) { | |
var arr = []; | |
var arrSentence = sentence.split(''); | |
// Get all vowels | |
arrSentence.forEach(el => { | |
if(['a','e', 'i', 'o', 'u'].indexOf(el.toLowerCase()) !== -1){ | |
arr.push(el); | |
} | |
} ); | |
// Get all consonants |
View app.js
This file contains 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
'use strict'; | |
// simple express server | |
var express = require('express'); | |
var app = express(); | |
var router = express.Router(); | |
app.use(express.static('public')); | |
app.get('/', function(req, res) { | |
res.sendfile('./public/index.html'); |
View example.js
This file contains 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
var defaults = { | |
number: 1, | |
bool: true, | |
magic: 'real', | |
animal: 'whale', | |
croutons: 'delicious' | |
}; | |
var options = { | |
number: 2, |
View jsbin.gewozekoxi.js
This file contains 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
function todayDate(){ | |
var day; | |
switch(new Date().getDay()){ | |
case 0: | |
day = "Sunday"; | |
break; | |
case 1: | |
day = "Monday"; | |
break; | |
case 2: |
View global-variables-are-bad.js
This file contains 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
// It is important to declare your variables. | |
(function() { | |
var foo = 'Hello, world!'; | |
print(foo); //=> Hello, world! | |
})(); | |
// Because if you don't, the become global variables. | |
(function() { |
NewerOlder