Skip to content

Instantly share code, notes, and snippets.

View calebpitan's full-sized avatar
👽
Nocturnal Juggernaut

Caleb Adepitan calebpitan

👽
Nocturnal Juggernaut
View GitHub Profile
@calebpitan
calebpitan / openapi.json
Created August 29, 2023 11:12
OpenAPI Spec
{
"openapi": "3.1.0",
"info": {
"title": "Kaybot",
"description": "Kaybot is a chatbot that can be utilized for lead generation in the field of digital marketing.",
"version": "1.0"
},
"paths": {
"/accounts/create": {
"post": {
@calebpitan
calebpitan / nim_game.js
Last active May 13, 2023 02:47
Nim Game (HackerRank)
/**
* Check if a number, n, is a prime number
* Complexity: O(sqrt(n))
*/
function isPrime(n) {
if (n === 1 || n === 0) return false
const lim = Math.floor(Math.sqrt(n))
for (let i = 2; i <= lim; i++) {
if (n % i === 0) {
return false
@calebpitan
calebpitan / Incremental-methods.md
Last active January 6, 2021 06:01
Difference between the popular incremental methods i++ and ++i

Incremental Methods

A lot of people do not know there is a difference existing between these two incremental methods popular in most programming languages.
Here I would simplify it and show you the difference.

The Diff.

The i++ statement is different from the ++i in that i++ returnns the value of i before incrementing; while the latter, ++i, as it should occur to you, since the ++ sign comes before i—increments first before returning i.

let input = "incremental methods";
let i = 0;
let char = input.charAt(i++); // here i = 0