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
1. Open your terminal | |
#In step 2, you can use your favorite editor instead of nano | |
2. sudo nano ~/.bashrc | |
3. Go to the end of your .bashrc file | |
4. Add these lines in your .bashrc file | |
function parse_git_branch () { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' |
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
//The user enter a string and as a result gets an array | |
function stringToArray(){ | |
let stringFromUser="firstname,secondname,surname,lastname" | |
let collectionOfCharacters=stringFromUser.split(",") | |
alert(`The result array is: ${collectionOfCharacters}`) | |
} |
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
//The user enter a string and as a result gets an array | |
function stringToArray(){ | |
let stringFromUser="this string" | |
let collectionOfCharacters=stringFromUser.split("") | |
alert(`The result array is: ${collectionOfCharacters}`) | |
} |
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
const updateElementsOnDOM= (elementModified)=>{ | |
document.getElementById(elementModified.name+"-item").value=elementModified.amount | |
} |
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
let password=""//Declare and initiallize the variable | |
//Let's say that get a password from a prompt is a good idea... just for demonstrate the use of lenght | |
password=prompt("Insert you password, it must have at least 5 characters")//Ask the user for the password | |
if(password.length>=5){//Validation of password lenght | |
alert("password set successfully!!")//Suppose that in addition to show message we store it in a DB | |
}else{ | |
alert("The password must have at least 5 characters")//The password is not the required... the the system should ask it again | |
} |
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
let message="Hello this is a string"//You can declare a String using double quotes | |
let greeting='Good morning!'//Also you can declare a String using sigle quotes |
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
let listOfCostumers=[]//This one is called Camell Case; as you can see the all the letters of the | |
//first word are lower case but the first letter of the following | |
//words begins with upperCase | |
let list_of_products=[]//This one is called under_score because you use "_" to separate | |
//each word of the name | |
let FirstNameOfCustomer="John"//This one is called Pascal Case, in this form you write | |
//the first letter of each word as UperCase |
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
let a=6 | |
if(a>5){ | |
const local="local variable" | |
console.log(local) | |
local="other value"//Trying to set the constant to anothe value... but this fails :O | |
} | |
console.log(local)//This throw an error because the scope of const is the same of let |
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
let a=6 | |
if(a>5){ | |
var local="local variable" | |
console.log(local)//This will print the value "local variable" | |
} | |
console.log(local)//This will print the value "local variable" with no one error |
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
let a=6 | |
if(a>5){ | |
let local="local variable" | |
console.log(local)//This will print the value "local variable" | |
} | |
console.log(local)//This will throw an error because local is out of scope |