Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const bool = true;
- const number = 12;
- const string = "hello world!";
- const array = [1, 22, 33];
- //const array2 = array;
- //array.push(4);
- const object = { 0: 1, 1: 2, c: 3 };
- //console.log(object.c);
- //const answer = number == 12 ? "yes" : "no";
- //number == 12 ? console.log("yes") : console.log("no");
- /*let answer2 = "no";
- if (number == 12) {
- answer2 = "yes";
- }*/
- /*while (true) {
- console.log(number);
- }*/
- //let counter = 1;
- /*while (true) {
- console.log(counter);
- counter = counter + 1;
- //counter++;
- //++counter;
- }*/
- /*const start = performance.now();
- while (counter <= 100) {
- console.log(counter);
- counter++;
- }
- const end = performance.now();
- console.log(end - start);
- */
- //wrażliwy na wielkość liter
- /* for (let i = 1; i <= 100; i++) {
- console.log(i);
- } */
- /*for (let i = 0; i < array.length; i++) {
- console.log(i);
- }*/
- /*for (let i = 0; i < array.length; i++) {
- console.log(i, array[i]);
- }*/
- /*
- array.forEach(function(value, index) {
- console.log(index, value);
- }); //funkcja anonimowa
- //nic nie zwraca jak VOID
- */
- /*
- array.map(function(value, index) {
- console.log(index, value);
- }); //mapowanie wartości, towrzy nową tablicę z taką samą ilością ale z przetworzonymi elementami
- */
- /*
- function add(a, b) {
- return a + b;
- }
- const add2 = function(a, b) {
- return a + b;
- };
- const add3 = (a, b) => {
- return a + b;
- };
- const add4 = (a, b) => a + b;
- const add5 = a => a + 5;
- console.log(add, add2, add3, add4, add5);
- const newArray = array.map(add5);
- const newArray2 = array.map(value => value + 5);
- console.log(newArray, newArray2);
- */
- /*
- const expr = "Oranges";
- switch (expr) {
- case "Oranges":
- console.log("Oranges are $0.59 a pound.");
- break;
- case "Mangoes":
- case "Papayas":
- console.log("Mangoes and papayas are $2.79 a pound.");
- break;
- default:
- console.log("Sorry, we are out of " + expr + ".");
- }
- */
- /*
- const value = 2;
- const translate = value => {
- switch (value) {
- case 1:
- return "one";
- case 2:
- return "two";
- case 3:
- return "three";
- case 4:
- return "four";
- case 5:
- return "five";
- case 6:
- return "six";
- case 7:
- return "seven";
- case 8:
- return "eight";
- case 9:
- return "nine";
- default:
- return "Sorry, we don't have " + value + " in our numbers.";
- }
- };
- console.log(translate(6));*/
- const random = Math.random();
- console.log(random);
- console.log(random * 10);
- console.log(Math.floor(random * 10));
- const getRandomInt = () => Math.floor(Math.random() * 10);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement