Skip to content

Instantly share code, notes, and snippets.

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

Daniel Cortes ldco2016

🏠
Working from home
  • Jacksonville, TX
View GitHub Profile
@ldco2016
ldco2016 / closure.js
Created December 27, 2017 01:43
This is an example of a closure for self-study
// Closures will blow your mind or make you pull your hair out!
// One of the most difficult topics is that of closures.
// So I will write a small function that returns a function
// that calculates how many years we have left to retirement.
// retirementAge passes the age someone has to have
// in order to retire
function retirement(retirementAge) {
var a = ' years left until retirement.';
@ldco2016
ldco2016 / app.js
Created December 25, 2017 23:32
IIFE allows us to have data privacy because it creates a new scope that is not visible from the outside scope.
// immediately invoked function expression
// its an anonymous function wrapped in parentheses
// Step 1: JS Runtime executes this line and this anonymous
// function is declared and immediately called because
// of (); operator below.
var budgetController = (function() {
// Step 2: Then this is declared and it returns an
// object below it.
// this part of the code is private
var x = 23;
@ldco2016
ldco2016 / javascript.md
Last active November 8, 2021 07:16
JavaScript: variables (ES6), arrays, conditionals, and loops

Create a Variable: Const

Let's dive in and see a variable in the wild. Here is how you declare a constant variable:

const myName = 'Arya';
console.log(myName);
// Output: Arya

Let's consider the above example:

@ldco2016
ldco2016 / anatomyHTML.md
Last active December 8, 2017 18:30
uses Markdown to explain/teach someone that has never seen or used HTML, the following tags: div, h1-h6, anchor, img, video

Of all the computer languages you will read about on my blog, HTML (hypertext markup language) is the simplest. That's because it's not a full fledged programming language. You can't write logical statements using HTML like you can with a programming language like Javascript (where, for instance, you can have code that behaves one way if some condition is true, and another if that condition is false). Instead, HTML is used to mark up content so web browsers know what kinds of content they're dealing with.

For instance, you can use an <h2> tag to tell the browser to render the word "Skills" as a heading, and you can use an unordered list with list items (<ul> and <li>s) to mark up the skills themselves and render them as a bulleted list.

For the most part, that's all there is to HTML: you take content and wrap it in the appropriate tags. You'll get plenty of practice with that throughout your projects, but in the remainder of this reading, I will go over enough background about HTML to code

q = gets.strip.to_i
for a0 in (0..q-1)
s = gets.strip
# your code goes here
# hackerrank
word = ""
index = 0
s.each_char do |c|
if c == "hackerrank"[index]
word += c
function main() {
var n = parseInt(readLine());
for (i = 1; i <=n; i++){
line = Array(n).fill(' ');
for (j = 0; j < i; j++){
line[j] = '#';
}
console.log(line.reverse().join(''))
}
function main() {
var n = parseInt(readLine());
arr = readLine().split(' ');
arr = arr.map(Number);
let positive = negative = zero = 0;
for (i =0; i < n; i++){
let current = arr[i];
if (current > 0) {
positive += 1;
function main() {
var n = parseInt(readLine());
var a = [];
for(a_i = 0; a_i < n; a_i++){
a[a_i] = readLine().split(' ');
a[a_i] = a[a_i].map(Number);
}
let sumPrimaryDiagonal = sumSecondaryDiagonal = 0;
function main() {
var S = readLine();
const expectedSignal = 'SOS';
let errorCount = 0;
for (i = 0, len = S.length; i <len; i += 3) {
const currentSignal = S.slice(i, i + 3);
if (currentSignal === expectedSignal) continue;
if (currentSignal[0] !== expectedSignal[0]) errorCount += 1;
if (currentSignal[1] !== expectedSignal[1]) errorCount += 1;
@ldco2016
ldco2016 / caesar-cipher.js
Created November 12, 2017 18:26 — forked from primaryobjects/caesar-cipher.js
Caesar Cipher algorithm, encrypt string wrap back around to letters
process.stdin.resume();
process.stdin.setEncoding('ascii');
var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;
process.stdin.on('data', function (data) {
input_stdin += data;
});