A Pen by Rodrigo Lira on CodePen.
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
// Create a funcion that will receive an integer number as a parameter and output to the log every number from 1 to the parameter. | |
// For each number divisible by 3, it should log the word "Fizz" instead of the number. | |
// For each number divisible by 5, it should log the word "Buzz" instead of the number. | |
// For each number divisible by 3 and 5, it should log the word "FizzBuzz" instead of the number. | |
function fizzBuzz(num) { | |
for (var i = 1; i <= num; i++) { | |
if (i % 15 == 0) console.log("FizzBuzz") | |
else if (i % 3 == 0) console.log("Fizz") | |
else if (i % 5 == 0) console.log("Buzz") | |
else console.log(i); |
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
// Implementation attempt of the Harmless Ransom Note algorithm. | |
// Create a function that receive two string parameters. | |
// The function should return "true" when the text int "noteText" can be created | |
// from words presented on "magazineText". It should return "false" otherwise. | |
function harmlessRansomNote(noteText, magazineText) { | |
var noteWords = noteText.split(" "); | |
var magazineWords = magazineText.split(" "); | |
var allWordsFound = true; | |
for (var i = 0; i < noteWords.length; i++) { |
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
// Implement a function that will receive a string as a parameter and will return | |
// true or false indicating whether the text is a palindrome (spelled the same way | |
// forward and backwards). The solution should avoid the use of regular expressions. | |
function isPalindrome(text) { | |
// TODO: convert accented characters to its ASCII equivalent character | |
// so it could be used by other languages. | |
var allowedChars = "abcdefghijklmnopqrstuvwxyz0123456789"; | |
var lowercaseText = text.toLowerCase(); | |
var forwardWordArray = []; |
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
// This file simulates an event handler executing an async method. | |
// LoginAsync() throws an unhandled exception. The compiler generated code has no way to schedule a continuation for the Task. | |
// There isn't anyway it can signal a faulted state. We can't "await" LoginAsync() because the method doesn't return anything. | |
// To solve this problem, we can change LoginAsync signature, replacing "void" with "Task". | |
private void LoginButton_Click(object sender, EventArgs args) { | |
try { | |
LoginAsync(); | |
} catch (Exception) { | |
} |
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
public class MyDatabaseSeeder | |
{ | |
public static async Task SeedAsync(MyDbContext context) | |
{ | |
if(!context.Foos.Any()) | |
{ | |
context.Foos.AddRange(GetPreconfiguredFoos()); | |
await context.SaveChangesAsync(); | |
} | |
This is a sample RxJs operator, as seen on the course RxJs in Practice.
A Pen by Rodrigo Lira on CodePen.
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
class Dropdown extends HTMLElement { | |
constructor() { | |
super(); | |
this._documentClick = this._closeOnDocumentClick.bind(this); | |
this._dropdownAlignment = "left"; | |
this._open = false; | |
this.attachShadow({ mode: 'open' }); | |
this.shadowRoot.innerHTML = /*html*/` |