Skip to content

Instantly share code, notes, and snippets.

View nick3499's full-sized avatar
🏠
Working from home

nick3499 nick3499

🏠
Working from home
  • USA
View GitHub Profile
@nick3499
nick3499 / fizzbuzz_for_loop.js
Last active April 26, 2018 00:06 — forked from AJ-Acevedo/fizzbuzz_for_loop.js
JavaScript - Fizz Buzz
function fizzBuzz(n) {
for (var i = 1; i <= n; i++) {
var fb = '';
if (i % 15 == 0) {
fb = 'FizzBuzz';
}
else if (i % 3 == 0) {
fb = 'Fizz';
}
else if (i % 5 == 0) {
@nick3499
nick3499 / nil_empty_blank_present_ffdierence_in_ruby
Last active May 29, 2018 04:56 — forked from pythonicrubyist/nil_empty_blank_present_ffdierence_in_ruby
Difference between nil?, empty?, blank? and present? in Ruby and Ruby on Rasils.
# nil? can be used on any Ruby object. It returns true only if the object is nil.
nil.nil? # => true
[].nil? # => false
{}.nil? # => false
"".nil? # => false
" ".nil? # => false
true.nil? # => false
# empty? can be used on some Ruby objects including Arrays, Hashes and Strings. It returns true only if the object's length is zero.
nil.empty? # NoMethodError: undefined method `empty?' for nil:NilClass