GithubHelp home page GithubHelp logo

khumam / fastcard Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 674 KB

We want to share from the community to the community various things related to developers, programming, engineering, and other related topics.

Home Page: https://fastcard.dev

JavaScript 8.04% TypeScript 88.22% CSS 3.73%
backend-roadmap basic-programming computer-science frontend-roadmap go-roadmap hardskill intermediate-programming java-roadmap javascript-roadmap php-roadmap python-roadmap react-roadmap roadmaps softskill fullstack-roadmap senior-programming

fastcard's Issues

[NEW] PHP Switch Operator

Category
PHP

Title
Switch Operator

Description
The switch operator in PHP is a control flow statement that allows you to execute different code blocks based on the value of an expression. It is similar to a series of if-else statements, but it can be more efficient for comparing the same expression to multiple values.

Cards
To use the switch operator, you first need to define a variable or expression to be evaluated. Then, you use the switch statement to compare the value of the variable or expression to a list of case statements. If the value matches one of the case statements, the code block associated with that case statement is executed. If the value does not match any of the case statements, the default code block (if it exists) is executed.

Card 01: Switch Operator

<?php

$color = "red";

switch ($color) {
    case "red":
        echo "The color is red.";
        break;
    case "green":
        echo "The color is green.";
        break;
    case "blue":
        echo "The color is blue.";
        break;
    default:
        echo "The color is unknown.";
}
// output: The color is red.
?>

[NEW] [WIP] Javascript

Category
Programming Language

Title
Javascript

Description
Javascript merupakan bahasa pemrograman populer yang banyak digunakan untuk kebutuhan Frontend dan memberikan pengalaman yang baik ke pengguna. Javascript biasanya akan jalan secara otomatis di browser tanpa harus menginstall aplikasi apapun

Cards
Please write the content of your cards. The content should be in markdown format so we can add your content easily. Or you can see this example below.

Getting Started with Javascript

File javascript bisa dibuat dengan ekstensi .js jika itu file yang terpisah dari HTML. Akan tetapi, juga bisa langsung diselipkan di dalam dokumen HTML dengan tag script. Jika filenya terpisah, bisa juga diimport dengan menggunakan tag yang sama yaitu script.

<!-- Import file .js -->
<script src="path/ke/file.js"></script>

<!-- Menulis langsung di HTML -->
<script>
   // Langsung tulis file javascriptnya
</script>

\

Javascript Variable

Untuk inisialisasi variable Javascript, perlu aksesor diawalnya. Variable javascript tidak memerlukan simbol apapun dalam penulisannya. Hanya saja perlu diketahui bahwa penulisannya tetap mengikuti aturan penulisan variabel secara umum.

// Variabel konstan
const data = 'your value';

// Variabel bisa diubah secara global
var user = 'your value';

// Variabel bisa diubah di block tertentu
let number = 13;

\

Javascript Variable aksesor

Secara umum ada 3 aksesor yang harus dipahami. Yaitu const, var, dan let. Term conts digunakan untuk membuat variabel konstan yang tidak bisa diubah lagi nilainya kecuali diinisialisasi ulang. Term var dan let merupakan aksesor yang mana nilai variable bisa diubah, bedanya var bersifat global dan let bersifat lokal.

// Const variable
const number = 1;
number = 2; // error karena variable number itu constant
const number = 2; // bisa karena diinisialisasi ulang
// Var dan let
var name = 'Jhon';
function process() {
  let age = 24;
  return "My name is " + name + " and I am " + age + " years old";
  // My name is Jhon and I am 24 years old
}

age = 21;
console.log("My name is " + name + " and I am " + age + " years old");
// My name is Jhon and I am undefined years old

\

Conditional statement in Javascript

Penggunaannya secara umum sama. Ada dengan menggunakan IF - ELSE IF - ELSEstatement ada juga yang menggunakan SWITCH Statement

// Menggunakan if - else if - else statement
if (condition) {
   return true;
} else if (another_condition) {
  return true;
} else {
  return false;
}
// Menggunakan switch statement
switch(value) {
  case condition:
     return true;
     break;
 case another_condition:
    return true;
    break;
 default:
    return false;
}

\

Looping in Javascript

Di dalam javascript, ada beberapa jenis perulangan, yang mana mungkin salah satunya sudah familiar. Yakni for loop, for in loop, for of loop, dan while loop.
\

Looping in javascript: For loop

Untuk for loop sama seperti di dalam bahasa pemrograman pada umumnya, Looping ini memiliki nilai awal, batasan akhir, dan kondisi looping yang sudah ditentukan.

for (initial_condition, final_condition, condition_behavior) {
  // Your code
}

// Example
for (let index = 0; index < 10; index++) {
  // your code will run 10x
}

\

Looping in javascript: For In loop

Di dalam javascript, terdapat metode for in loop. Metode ini digunakan untuk mengambil key dari sebuah objek.

const data = { name: "Jhon", age: 24, address: "New York" };
let text = "";

for (key in data) {
  text += data[key];
}

console.log(text);
// Jhon24New York

\

Looping in javascript: For Of loop

Untuk mengulang sebanyak panjang dari array atau objek yang diulang, kita bisa menggunakan For Of Loop.

const data = ['a', 'b', 'c'];

for (const element of data) {
  console.log(element);
}

// Expected output: "a"
// Expected output: "b"
// Expected output: "c"

\

Looping in Javascript: While loop

Untuk looping while loop cara penggunaannya sama seperti di bahasa pemrograman pada umumnya. Loop ini akan terus berjalan jika kondisi tidak bernilai false

while(condition) {
  // your code here
}

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.