🤓 Code Snippets

Share and store your most common code snippets. Use our snippet explanation generator to use AI to try and explain the code.

const arithmeticProgression  = (n, lim) =>
  Array.from({ length: Math.ceil(lim / n) }, (_, i) => (i + 1) * n );


arithmeticProgression(5, 25); // [5, 10, 15, 20, 25]

Dhairya Shah

2 years ago

2
<!DOCTYPE html>
<html>
<head>
	<title>My First Web Page</title>
</head>
<body>
          <h1>Asslam O Alikum! World</h1>
</body>
</html>
3

mktoho

2 years ago

2
from os import system
system('echo "Hello, world!"')

Jothin kumar

2 years ago

3
from itertools import cycle

my_list = ['list element 1', 'list element 2']

for list_element in cycle(my_list):
    print(list_element)
"""
The above for loop would output:
list element 1
list element 2
list element 1
list element 2
list element 1
list element 2
and so on...
"""

Jothin kumar

2 years ago

2
def find_factorial(num):
    result = 1
    count = 1
    while count <= num:
        result *= count
        count += 1
    return result

Jothin kumar

2 years ago

2
/*****
*
* Here is the HTML that should trigger the following method:
* <button wire:click="removeMe">Remove</button>
* Thsi will call the removeMe() method inside a Livewire controller
*
*****/

public function removeMe()
{
  $this->image = '';
}

Tony Lea

2 years ago

const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n;

validateNumber('10'); // true

Abhiraj Bhowmick

2 years ago

2
<link rel="stylesheet" type="text/css" href="">

Valeria

2 years ago

1
Load More