Skip to content

Instantly share code, notes, and snippets.

View aditya2000's full-sized avatar

Kunwar Aditya aditya2000

  • New Delhi, India
View GitHub Profile
// Importing the required modules
const express = require('express');
const mongoose = require('mongoose');
const read = require('stream-read');
const fs = require('fs');
// initialising the app
const app = express();
const mongoURI = 'XXX'
import React, { Component } from 'react';
import { StyleSheet, View, Button } from 'react-native';
import Mapbox from '@mapbox/react-native-mapbox-gl';
Mapbox.setAccessToken('My Token');
export default class App extends Component {
constructor(props) {
import React, { Component } from 'react';
import { StyleSheet, View } from 'react-native';
import Mapbox from '@mapbox/react-native-mapbox-gl';
Mapbox.setAccessToken('MY-PUBLIC-KEY');
export default class App extends Component {
constructor(props) {
@aditya2000
aditya2000 / index.html
Created April 9, 2018 12:43
Pomodoro Clock
<html>
<head>
<title>Pomodoro Clock</title>
<style>
@import url('https://fonts.googleapis.com/css?family=Berkshire+Swash');
</style>
</head>
<body>
<div class="container" id="container">
@aditya2000
aditya2000 / index.html
Created April 4, 2018 10:27
Javascript Calculator
<html>
<head>
<title>Javascript Calculator</title>
<style>
@import url('https://fonts.googleapis.com/css?family=Orbitron');
@import url('https://fonts.googleapis.com/css?family=Dancing+Script');
</style>
</head>
<body>
<div class="container" id="container">
@aditya2000
aditya2000 / index.html
Created April 4, 2018 10:25
Javascript Calculator
<html>
<head>
<title>Javascript Calculator</title>
<style>
@import url('https://fonts.googleapis.com/css?family=Orbitron');
@import url('https://fonts.googleapis.com/css?family=Dancing+Script');
</style>
</head>
<body>
<div class="container" id="container">
1. getTokens(rawString) : -This function takes an argument(rawString) and returns the array of words in rawString.
-This function uses some built in functions such as toLowerCase(), fliter(),split() and
sort().
-The fliter(Boolean) filters all the falsy values from an array.
-Inside the split() function a regular expression is written which helps in splitting the
words in the text.
2. mostFrequentWord() : -Inside this function a variable "words" is defined which stores the array of the words
which is returned by the function getTokens().
-Also an empty object wordFrequency is defined which will store the frequency of each
word in the words array.
var scratchData = [
{id: 22, foo: 'bar'},
{id: 28, foo: 'bizz'},
{id: 19, foo: 'bazz'}
];
function findById(items, idNum) {
return items.find(function(item) {
return item.id === idNum;
});
function createMyObject() {
var myObject = {
foo : 'bar',
answerToUniverse: 42,
'olly olly': 'oxen free',
sayHello: function(){
return 'hello';
}
}
return myObject;
When a function alters values outside of the scope then we call it a 'side effect'. Side effects can be both bad and good. When a function is intended to alter the values outside it's scope, then it not a problem. But it creates a problem when it is unintended and alters the values outside of it's scope. When this happens, the function starts returning different values whenever it is called with same set of values.