GithubHelp home page GithubHelp logo

rafase282 / my-freecodecamp-code Goto Github PK

View Code? Open in Web Editor NEW
1.5K 196.0 344.0 1.37 MB

My code from the bootcamp.

Home Page: http://rafase282.github.io/My-FreeCodeCamp-Code

JavaScript 54.84% HTML 24.01% CSS 10.33% Ruby 0.38% Pug 6.63% Sass 3.81%
freecodecamp-challenge javascript journal wiki explanation

my-freecodecamp-code's Introduction

My Work From FreeCodeCamp

This repository is not for an app but more as a journal , where I keep the record of everything that I have done and learned from FreeCodeCamp. I decided to use a wiki as I can put more information easily on it. You will find the code easily on the directories, and more information on the wiki section

I will try to keep everything updated. Please keep in mind that this started as a journal and so I have kept the code as it was , when I solved the original challenges. This means that I did not re-write them with more advanced techniques or improved on them but instead leave them as is until the problems are updated and they need thus the solution needs to be updated too.

If you are also a part of the camp or would like to contribute in any way then feel free to contact me. The purpose of this is for reference and learning material overall, for everyone as it is public. If you encounter a solution that no longer works then please open an issue so that I can work on it. While I do not accept solutions from other people for this repo, feel free to send pull request with fixes to typos or better explanations and examples. Shortly after I started this wiki, I became part of FreeCodeCamp and manage the wiki there, so if you want updated solutions with more advance solutions you will find them there instead.

If you find this useful then follow and start it, feel free to share it also.

If you want to contribute to the repo in general with fixes such as typos, better explanations or anything other than replacing my code solutions then follow this guide. How To Contribute To The Repository.

Contact me

Rafael Rodriguez

@Rafase282

Github | FreeCodeCamp | CodePen | LinkedIn | Blog/Site | E-Mail

Links

  • The Wiki
  • The Project page Feel free to share it.

Code Status:

I'm thinking about working on the Data Visualization before I work on the dynamic web apps. This means learning sass, D3, react

Wiki Status:

I have done everything that I completed codewise, so i will be working in sync with the coding part..

Completed:

  1. HTML5 and CSS
  2. Responsive Design with Bootstrap
  3. jQuery
  4. Basic JavaScript
  5. Object Oriented and Functional Programming
  6. Basic Algorithm Scripting
  7. Basic Front End Development Projects
  8. Intermediate Algorithm Scripting
  9. Upper Intermediate Algorithm Scripting
  10. Automated Testing and Debugging
  11. Advanced Algorithm Scripting
  12. Angular.js
  13. Git
  14. Gear up for Success
  15. Get Started with Free Code Camp
  16. Intermediate Front End Development Projects
  17. Node.js and Express.js
  18. MongoDB
  19. API Projects

To-DO:

  1. Dynamic Web Applications
  2. Data Visualization Certification
  3. Full Stack Development Certification
  4. Coding Interview Preparation

Contribute to my wiki.

If you would like to contribute then feel free to clone, fork, create a branch, add or edit content and submit a pull request to this repo https://github.com/Rafase282/MyFCCWiki then I will check it out and merge it. Then push it to the live wiki. This also could serve as a repo for only the wiki if you want to keep your own but do not want to also clone my code.

my-freecodecamp-code's People

Contributors

abhipaul-99 avatar arjav96 avatar ayushi-blip avatar chuanfengzhang avatar rafase282 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

my-freecodecamp-code's Issues

Advanced scripting 3 - Exact Change 1 not working

checkCashRegister(19.50, 20.00, [["PENNY", 0.01], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 1.00], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]) should return "Insufficient Funds".

This one is returning an incorrect array and not insufficient Funds

Make a person challenge

I think you're probably wrong on this challenge. According to your original code, it's not possible to change fullName when using function setFirstName or setLastName. Here is my fix to make it work.

var Person = function(firstAndLast) {

  var arr = firstAndLast.split(' ');

  this.getFirstName = function() {
    return arr[0];
  };

  this.getLastName = function() {
    return arr[1];
  };

  this.getFullName = function() {
    return arr.join(' ');
  };

  this.setFirstName = function(first) {
    arr[0] = first;
  };

  this.setLastName = function(last) {
    arr[1] = last;
  };

  this.setFullName = function(firstAndLast) {
    arr = firstAndLast.split(' ');
  };
};

var bob = new Person('Bob Ross');
bob.getFullName();

Target the same element with multiple jQuery Selectors

The code you have adds three classes to #target1 when you're only supposed to only add one class with each of your three selectors. The last selector should add the class "btn-primary" to target one.

<script> $(document).ready(function() { $("button").addClass("animated"); $(".btn").addClass("shake"); $("#target1").addClass("btn-primary"); }); </script>

Issue with Spoiler Code for Lesson Review Record Collection

On the page Lesson Review Record Collection the spoiler code and the hints does not create the empty array needed before adding the new value to the nested object properties. Adding in collection[id].tracks=[] in the else if (prop!=='tracks') fixes this.

So the function should look like such:

function updateRecords(id, prop, value) {
 if (value===''){
   delete collection[id][prop];
 } else if (prop !== 'tracks') {
   collection[id].tracks=[];
   collection[id][prop] = value;
 } else {
   collection[id][prop].push(value);
 }

  return collection;
}

Basic JavaScript: Record Collection

Hey there, you should change the code in order to cover this requirement: if prop is "tracks" but the album doesn't have a "tracks" property, create an empty array before adding the new value to the album's corresponding property.

Something like the following should work:

function updateRecords(id, prop, value) {
  if (value === '') {
    delete collection[id][prop];
  } else if (prop !== 'tracks') {
    collection[id][prop] = value;
  } else {
     !collection[id].hasOwnProperty('tracks') ? collection[id][prop] = [] 
                                              : collection[id][prop];
     collection[id][prop].push(value);
  }   
  return collection;
}

Roman Numeral Converter Solution needs Update

They updated the requirements and you need to add a new "imaginary" integer, that follows after M(1000), because of the code snippet
decimalValue[index + 1] > numeral (line 15)

I got the source code, that worked for me. I called the imaginary unit Y for 10000

function convertToRoman(num) {
  // Create arrays with default conversion with matching indices.
  var decimalValue = [1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000, 10000];
  var romanValue = ['I', 'IV', 'V', 'IX', 'X', 'XL', 'L', 'XC', 'C', 'CD', 'D', 'CM', 'M', 'Y'];

  // Create a copy of num to work on and an empty string variable for the final roman number
  var numeral = num;
  var roman = '';

  // While the decimal number is greater than 0,
  while (numeral > 0 && numeral < 4000) {
    // Loop through the indices of the decimalValue array.
    for (var index = 0; index <= decimalValue.length; index++) {
      // Get the maximum decimal number less or equal then the decimal number.
      if (decimalValue[index] <= numeral && decimalValue[index + 1] > numeral) {
        // Add the Roman numeral & decrease numCopy by the decimal equivalent.
        roman += romanValue[index];
        numeral -= decimalValue[index];
      }
    }
  }

  return roman;
}

convertToRoman(12);

Solution to Roman-Numeral-Converter is buggy

Hi there,
I was just going through your code and I noticed that your solution leaves a trail to an infinite loop and in order to avoid that you need to add an extra element in your array N for 10000.

.

can anybody tell me how to : Give the text input in your form the class form-control.

<style> h2 { font-family: Lobster, Monospace; }

.thick-green-border {
border-color: green;
border-width: 10px;
border-style: solid;
border-radius: 50%;
}

</style>

CatPhotoApp

A cute orange cat lying on its back.
Three kittens running towards the camera.
Like
Info
Delete

Things cats love:

  • cat nip
  • laser pointers
  • lasagna

Top 3 things cats hate:

  1. flea treatment
  2. thunder
  3. other cats
Indoor
Outdoor
Loving
Lazy
Crazy
Submit

Bonfire-Truncate-a-string has an error

@Rafase282 . The first,thank you very much for your good tutorial, but in this wiki page ( https://github.com/Rafase282/My-FreeCodeCamp-Code/wiki/Bonfire-Truncate-a-string) I have another idea.

eg:

function truncate(str, num) {
    var truncd = '';
    if (str.length > num) {
        truncd = str.slice(0,num-3) + '...';
        return truncd;
    }
    return str;
}
truncate("A-tisket a-tasket A green and yellow basket", 11);

I has runed in chrome console:

> truncate("A-tisket a-tasket A green and yellow basket", 11);
< "A-tisket..."
> truncate("A-tisket a-tasket A green and yellow basket", 1);
< "A-tisket a-tasket A green and yellow bask..."
> truncate("A-tisket a-tasket A green and yellow basket", 2);
< "A-tisket a-tasket A green and yellow baske..."
> truncate("A-tisket a-tasket A green and yellow basket", 3);
< "..."
> truncate("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length);
< "A-tisket a-tasket A green and yellow basket"

if num <=3 , the truncate() is not the best. I will change the function, like this:

function truncate(str, num) {
  var truncd = "";

  if (str.length > num && num > 3) {
    truncd = str.slice(0, num -3) + "...";
  } else if (str.length > num && num <= 3) {
    truncd = str.slice(0, num) + "...";
  } else {
    truncd = str.slice(0, num);
  }

  return truncd;
}

truncate("A-tisket a-tasket A green and yellow basket", 11);

Chrome console result:

> truncate("A-tisket a-tasket A green and yellow basket", 11);
< "A-tisket..."
> truncate("A-tisket a-tasket A green and yellow basket", 1);
< "A..."
> truncate("A-tisket a-tasket A green and yellow basket", 2);
< "A-..."
> truncate("A-tisket a-tasket A green and yellow basket", 3);
< "A-t..."
> truncate("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length);
< "A-tisket a-tasket A green and yellow basket"

If you have any better solutions, welcome to share

Don't think it's still possible to check if account is closed [Twitch API]

I'm working on this project now and since it is suggested to use the third party api in lieu of registering for a twitch.tv api key, I don't think one of the user stories works now. The json response for one of the suggested closed account users (comster404) is as follows:

{"stream":null,"_links":{"self":"https://api.twitch.tv/kraken/streams/comster404","channel":"https://api.twitch.tv/kraken/channels/comster404"}}

this is the same response as an active offline account, so I don't see a way to distinguish between the two.

Intermediate Algorithm Scriptiing - 20 Bonfire Everything Be True.js

if (collection[c].hasOwnProperty(pre) || collection[c][pre] == pre) {
counter++;
}

Hi I'm trying your code in my code camp
This condition give wrong result you can change with && and don't compare collection[c][pre] with pre but just collection[c][pre] so that become's correct
Thx for attention

"Ans" button in freeCodeCamp's JavaScript Calculator example not functional

This challenge was a lot of fun! I'm not sure whether someone had already pointed this issue out (I couldn't find someone else posting about it anywhere), but the button in the example program that stores the last answer to be used later (the "ANS" button) doesn't do anything; For example when you type "2+2=", 4 appears, then when you type "Ans+2=" you simply get 2, meaning it starts from 0 again, and nothing seems to be stored for later use.

I'm not sure if this would be considered a bug or not but I thought it was odd to have a button that doesn't do anything.

Here is the link to my code if it's any help: https://codepen.io/LeFonze/pen/pbzYGo

Challenge "Record Collection" Changed on FreeCodeCamp

Hi there, I was going through the questions on FCC and I realized that more restrictions has been put on the Challenge Record Collection than the one you have on wiki.

Since there is no current way I know to contribute to the wiki on Github, I will just post my working solution down below so you can update it on yours.

New Passing Solution

// Setup
var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    },
    "5439": {
      "album": "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
  if (value === "") {
    delete collection[id][prop];
  }

  else if (prop !== "tracks") {
    collection[id][prop] = value;
  }

  else if (!collection[id].hasOwnProperty("tracks")) {
    collection[id][prop] = [];
    collection[id][prop].push(value);
  }

  else {
    collection[id][prop].push(value);
  }

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");

Outdated solution.

Hi!

The code you proposed doesn't work that well ;) My final version below:

`function checkCashRegister(price, cash, cid) {
var totalChange = +(cash - price).toFixed(2);
var stdCurr = [0.01, 0.05, 0.10, 0.25, 1, 5, 10, 20, 100];
var currType;
var stdCurrAmount;
var currCurrency;
var changeArr = [];
var totalCash = +cid.map(function(money) {
return money[1];
}).reduce(function(cash1, cash2) {
return cash1 + cash2;
}).toFixed(2);

var resultAmount = 0;

function check(result) {
for (var i = 0; i < result.length; i++){
resultAmount += result[i][1];
}

if (resultAmount < totalChange) {
  return false;
} else {
  return true;
}

}

if (totalChange > totalCash) {
return 'Insufficient Funds';
} else if (totalChange === totalCash) {
return 'Closed';
}

for (var i = +cid.length - 1; i >= 0; i--) {
currCurrency = +cid[i][1].toFixed(2);
currType = cid[i][0];

if (+stdCurr[i].toFixed(2) <= +totalChange.toFixed(2)) {

  stdCurrAmount = Math.floor(currCurrency / stdCurr[i]);

  if ((stdCurr[i] * stdCurrAmount) >= totalChange) {
    stdCurrAmount = Math.floor(totalChange / stdCurr[i]);
  }

  currCurrency = +(stdCurr[i] * stdCurrAmount).toFixed(2);
  totalChange = +(totalChange - currCurrency).toFixed(2);

  cid[i][1] = currCurrency;
  changeArr.push([currType, currCurrency]);
}

}

if (check(changeArr) === false){
return 'Insufficient Funds';
} else {
return changeArr;
}

}`

jQuery Lesson 6

<script> $(document).ready(function() { $("button").addClass("animated"); $(".btn").addClass("shake"); $("#target1").addClass("animated shake #btn-primary"); }); </script>

In the above code, you should be targeting one element by adding one class at a time.
Correction should be $("#target1").addClass("btn-primary")

Thanks for the great work bro!!

Bonfire: Make a person

Hello Rafael,

i tried your code for the Make a person bonfire but it has not worked. I modified it to the following and it worked again. Please give me feedback.

var Person = function(firstAndLast) {

  var arr = firstAndLast.split(' ');

  this.getFirstName = function() {
    return arr[0];
  };

  this.getLastName = function() {
    return arr[1];
  };

  this.getFullName = function() {
    return arr[0] + " " + arr[1];
  };

  this.setFirstName = function(first) {
    arr[0] = first;
  };

  this.setLastName = function(last) {
    arr[1] = last;
  };

  this.setFullName = function(firstAndLast) {
    arr = firstAndLast.split(' ');
  };
};

'Truncate a string' no longer valid

Firstly, thank you for putting your code up for others to enjoy and benefit from. I solved the following bonfire but wondered if my code could be cleaner, so I looked around.

I saw your code. While I am sure it used to work, it now does not. I also specify the criteria it now does not qualify.

Bonfire: https://www.freecodecamp.org/challenges/truncate-a-string
Your code: https://github.com/Rafase282/My-FreeCodeCamp-Code/wiki/Bonfire-Truncate-a-string
How I solved it: https://pastebin.com/vdBbAurN
The part you didn't qualify: If the string (str) is less than or equal to 3 then do not count '...' towards the truncate total.

Bonfire Truncate a string

function truncate(str, num) {
var truncd = '';
if (str.length > num) {
truncd = str.slice(0,num-3) + '...';
return truncd;
}
return str;
}

does not accommodate
truncateString("A-", 1) should return "A...".
truncateString("Absolutely Longer", 2) should return "Ab...".

Fix------

function truncateString(str, num) {
var truncString = '';
if (num < 3) {
truncString = str.slice(0, num) + '...';
return truncString;
}
else if(str.length > num) {
truncString = str.slice(0, num - 3) + '...';
return truncString;
}
return str;
}

Geolocation does not work (edit)

In Local Weather App (intermediate front-end project),

Custom background does not change base on weather conditions.

Code below is flawed: (calling an array of images on the jQuery function will not be successful)
getWeather = function(data) {
// other code in between.
// Array of backgroudn images.
var imgs = ['url("http://i.imgur.com/eI5KLUW.jpg")',
'url("http://i.imgur.com/rG0P1ro.jpg")', 'url("http://i.imgur.com/voCuONs.jpg")',
'url("http://i.imgur.com/5tFHSKa.jpg")',
];

// Select custom backgroudn image according to temperature range.
if (temp >= temps[0]) {
  $('body').css('background-image', imgs[0]);
} else if (temp < temps[0] && temp >= temps[1]) {
  $('body').css('background-image', imgs[1]);
} else if (temp < temps[1] && temp >= temps[2]) {
  $('body').css('background-image', imgs[2]);
} else if (temp < temps[2]) {
  $('body').css('background-image', imgs[3]);
}

};

Correct version: (sample)
$("body").css("background-image", "url(https://github.com/chrisjim316/freeCodeCamp-/blob/master/09-Intermediate-FE-Projects/Local%20Weather%20App/Images/backgroundChanging/thunderstorm.jpg?raw=true)");

Basic Javascript: Profile Lookup Challenge solution not working

Lookup Challenge

"Get a hint" on freecodecamp is down (error 500 - internal server error), so I found this github page.

Unfortunately the solution given does not work / is not accepted by fcc, but this does

function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i=0; i < contacts.length; i++) {
    if (contacts[i].firstName === firstName) {
      if (contacts[i].hasOwnProperty(prop)) {
        return contacts[i][prop];
      }
      else {
        return "No such property";
      }
    }
  }
  return "No such contact";
// Only change code above this line
}

I think .some() is not known to beginners at that point.

Bonfire Exact Change edge cases of concern?

There are cases where there is enough change in the drawer, but not enough useful change. For example, if there's 1 $100 in the drawer, and you need $0.37 in change, you couldn't really make the change. Seems like it would be better to find the sum of useful change in drawer, rather than all change in drawer....

Chaining If Else statements

Hello,

I'm pretty sure my code is correct but For the Chaining If Else Statements lesson, it won't acknowledge that it's correct so I can't proceed:

capture 07

Boo who free freecodecamp.org

function booWho(bool) {
// the fastet way to solve this problem
return typeof bool==="boolean";
}

booWho(null);

/* another way to solve it

function booWho(bool) {
if (bool===true || bool===false){
return true;

}
else{
return false;
}
return bool;
}

booWho(false);
*/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.