How good you at debug?
// test-1.js
let array = [0];
if(array != false) {
if(array[0]) {
array.push(1, 2, 3, 4);
} else {
array.splice(1, 2, 3, 4);
}
} else {
array = array + [937, 99, 92];
}
console.log(array);
// test-2.js
let array = [null];
if(array == 0) {
array.push(0.1 + 0.2);
} else {
array.length = 0;
array.push(1, 2, 3);
}
console.log(array);
// test-3.js
let a = new Number('43');
if(a == 43) {
if(a < Math.min()) {
console.log(`${typeof a} is {} in js`);
} else {
console.log(`${a + '2'} == 432`);
}
} else {
console.log(`1 == 1 // => ${a instanceof Object}`);
}
# test-4.rb
LETTERS = ['a', 'U', 'b', 'd', 'Z']
first = LETTERS.min
last = LETTERS.max(1)
if last.class == String
last = "B"
else
last = last[0].upcase
end
puts "We known R#{first}#{last}Y!"
# test-5.rb
begin
first = [1, 2, 3, 4, 5].slice(-2.50, 1)
if first.is_a?(Numeric)
result = first / Float::INFINITY
puts "#{result} is #{result.class}"
else
chars = first.map(&:to_s) + ['A', '0']
puts "#{chars.min}..#{chars.max}"
end
rescue => exception
puts "It was easy"
end
# test-6.rb
words = "Norway=Egypt>Denmark".split(/(=|>)/)
if words.length == 3
puts words.map(&:upcase).join(?&)
else
puts words.sort_by(&:size).map{|w| w[0].upcase }.join
end
Enjoy beer
don't waste time on debug
WAT tribute
By Sergey Pchelincev
WAT tribute
- 1,662