Skip to content

Instantly share code, notes, and snippets.

View essamamdani's full-sized avatar
🌗
Working from home

Essa Mamdani essamamdani

🌗
Working from home
View GitHub Profile
@essamamdani
essamamdani / iteratingSet.js
Created April 27, 2020 15:25
iterating through keys and values in set
var setA = new Set();
setA.add("maps").add("filters").add("generators").add("arrow functions");
setA.has(“promises”);
setA.has(“generators”);
for(const s in setA.values())
document.write(s + "<br/>");
@essamamdani
essamamdani / DeleteItem.js
Created April 27, 2020 13:51
deleting and emptying item in set
var setA = new Set();
setA.add(“maps”);
setA.add("maps").add("filters").add("generators").add("arrow functions");
setA.delete(“filters”);
setA.clear();
@essamamdani
essamamdani / checkItem.js
Created April 27, 2020 13:49
Check an item from the Set:
var setA = new Set();
setA.add(“maps”);
setA.add("maps").add("filters").add("generators").add("arrow functions");
setA.has(“promises”);
setA.has(“generators”);
@essamamdani
essamamdani / AddInSet.js
Last active April 27, 2020 13:44
adding single and multiple values in a set in JS
var setA = new Set();
setA.add(“maps”);
setA.add("maps").add("filters").add("generators").add("arrow functions");
console.log(setA.size)
@essamamdani
essamamdani / setJS.js
Created April 27, 2020 13:32
declaration of set in JS
var setA = new Set();
@essamamdani
essamamdani / MultipleLinesComments2
Created April 21, 2020 12:48
These types of comments can also be used when you want to test some functionality like you created a function but comment that out and create one more with a slight difference to check the working.
<script>
var a = 2;
var b = 7;
var c = 2;
document.write("Answer is " + sum());
/* function sum(){
return a+b;
} */
@essamamdani
essamamdani / MultipleLinesComments
Created April 21, 2020 12:46
Multi-line / Block comments are used when you need to comment on multiple lines that are placed together.
<script>
/* initialize and call a function
which takes users name in a variable
and welcome them on page */
function greetingMessage() {
var name = promp("Type your first name.");
document.write("Welcome to our page " + name + "!");
}
@essamamdani
essamamdani / SingleLineComment
Created April 21, 2020 12:43
Single line comments also use as inline comments which means that they appear at the end of code.
<script>
var x = 5; //declare and initalize the variable x
var y = x * 4; //multiply the value of x four times
</script>
<script>
//declaring a function to sort numbers
function sortNumbers(){
//declare and initialize array of numbers
const nums = [3,14,45,12];
//sort the array and display the result
document.write(nums.sort());
}
sortNumbers();
<script>
//prints Hello World
document.write("Hello World");
</script>