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 foo = 1; | |
function bar() { | |
if (!foo) { | |
var foo = 10; | |
} | |
alert(foo); | |
} | |
bar(); |
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 printLastName; | |
printLastName = function() { | |
console.log("McClane") | |
} | |
var printFirstName; // undefined | |
printLastName() // "McClane" | |
printFirstName() // Uncaught TypeError: printFirstName is not a function |
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
printLastName() // "McClane" | |
printFirstName() // Uncaught TypeError: printFirstName is not a function | |
function printLastName() { | |
console.log("McClane") | |
} | |
var printFirstName = function() { | |
console.log("John") | |
} |
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
#!/usr/bin/env ruby | |
require "./lib/check_parans/cli" | |
CheckParans::CLI.start |
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
require 'thor' | |
require 'CheckParans' | |
module CheckParans | |
class CLI < Thor | |
desc "check_parans", "Determines if parenthesis are valid" | |
def check_parans(string) | |
puts CheckParans.valid_parentheses(string) | |
end | |
end | |
end |
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
require 'CheckParans' | |
our_test_code_1 = 'const result = array.map((element)=>element*2)' | |
our_test_code_2 = 'const result = array.map((element)=>element*2))' | |
CheckParans.valid_parentheses(our_test_code_1) | |
CheckParans.valid_parentheses(our_test_code_2) |
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
module CheckParans | |
def self.valid_parentheses(string) | |
only_parants = string.scan(/([()])/) | |
if only_parants.empty? | |
true | |
elsif only_parants.length == 1 | |
false | |
end | |
k = false | |
until k == true |
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
RSpec.describe CheckParans do | |
it "has a version number" do | |
expect(CheckParans::VERSION).not_to be nil | |
end | |
it "gives true when parentheses are valid" do | |
expect(CheckParans.valid_parentheses('((sdf)())')).to eql(true) | |
end | |
it "gives false when parentheses are invalid" do | |
expect(CheckParans.valid_parentheses('(sdfs')).to eql(false) | |
end |
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
require_relative 'lib/check_parans/version' | |
Gem::Specification.new do |spec| | |
spec.name = "check_parans" | |
spec.version = CheckParans::VERSION | |
spec.authors = ["yourName"] | |
spec.email = ["yourEmail@gmail.com"] | |
spec.summary = "This is a test gem" | |
spec.description = "This gem checks parenthesis validity" |
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
require_relative 'lib/CheckParans/version' | |
Gem::Specification.new do |spec| | |
spec.name = "CheckParans" | |
spec.version = CheckParans::VERSION | |
spec.authors = ["yourName"] | |
spec.email = ["yourEmail@gmail.com"] | |
spec.summary = %q{TODO: Write a short summary, because RubyGems requires one.} | |
spec.description = %q{TODO: Write a longer description or delete this line.} |