Hello Le Wagon 👋
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <link rel="stylesheet" href="style.css"> | |
| <title>Playground - JavaScript 101</title> | |
| </head> | |
| <body> |
This file contains hidden or 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
| students = ["Harry Potter", "Ronald Weasley", "Hermione Granger"] | |
| # INDEXES 0 1 2 | |
| # CRUD | |
| # CREATE -> add new element | |
| students << "Draco Malfoy" | |
| students.push("Draco Malfoy") | |
| p students |
This file contains hidden or 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 acronymize(sentence) | |
| if sentence == "" | |
| return "" | |
| else | |
| # 1. split sentence into words | |
| words = sentence.split(" ") | |
| # 2. create new array with first letters only | |
| letters = words.map do |word| | |
| word[0].capitalize |
This file contains hidden or 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
| students = [ "Peter", "Mary", "George", "Emma" ] | |
| student_ages = [ 24 , 25 , 22 , 20 ] | |
| # INDEXES 0 1 2 3 | |
| # Index is the only thing connecting both arrays | |
| # We need to use it to print our list | |
| students.each_with_index do |name, index| | |
| age = student_ages[index] | |
| puts "#{name} is #{age} years old" |
This file contains hidden or 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
| '01': Ain | |
| '02': Aisne | |
| '03': Allier | |
| '04': Alpes-de-Haute-Provence | |
| '05': Hautes-Alpes | |
| '06': Alpes-Maritimes | |
| '07': Ardèche | |
| '08': Ardennes | |
| '09': Ariège | |
| '10': Aube |
This file contains hidden or 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 'date' | |
| require 'yaml' | |
| SSN_PATTERN = /^(?<gender>[1-2])\s?(?<birth_year>\d{2})\s?(?<birth_month>0[1-9]|1[0-2])\s?(?<department>0[1-9]|[1-9]\d)\s?(?<random_numbers>(\d{3}\s?){2})(?<key>\d{2})$/ | |
| def french_ssn_info(ssn_number) | |
| return 'The number is invalid' if ssn_number.empty? | |
| match_data = ssn_number.match(SSN_PATTERN) |
This file contains hidden or 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 list(items) | |
| items.each_with_index do |gift_hash, index| | |
| # 2.1. Display each gift information | |
| # TERNARY IF | |
| # CONDITION ? code_executed_if_true : code_executed_if_false | |
| status = gift_hash[:bought] ? "[X]" : '[ ]' | |
| #=> TRUE/FALSE | |
| puts "#{index + 1} - #{status} #{gift_hash[:name]} - $#{gift_hash[:price]}" | |
| end | |
| end |
This file contains hidden or 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 'open-uri' | |
| require 'nokogiri' | |
| # 1. Capture the href/path/url for the top 5 movies | |
| def fetch_movie_urls | |
| url = 'https://www.imdb.com/chart/top' | |
| # 1. 'visit' the page, and retriving all the content | |
| html_file = URI.open(url, "Accept-Language" => "en-US").read | |
| # 2. parse the html using nokogiri | |
| html_doc = Nokogiri::HTML(html_file) |
This file contains hidden or 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 "csv" | |
| # TODO - let's read/write data from beatles.csv | |
| filepath = "data/beatles.csv" | |
| # PARSING CSV | |
| # CSV.foreach(filepath, headers: :first_row) do |row| | |
| # # puts "first name: #{row[0]}, last name: #{row[1]}, instrument: #{row[2]}" // BEFORE ADDING headers: :first_row | |
| # puts "first name: #{row['First Name']}, last name: #{row['Last Name']}, instrument: #{row['Instrument']}" |
OlderNewer