Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Nikhil Singh nikhilmufc7

🏠
Working from home
View GitHub Profile
View Shouter
function shouter(whatToShout) {
// your code here
}
/* From here down, you are not expected to
understand.... for now :)
Nothing to see here!
View Divisible
function isDivisible(divisee, divisor) {
return divisee % divisor === 0;
}
/* From here down, you are not expected to
understand.... for now :)
Nothing to see here!
View Error drill
function main() {
try {
doAllTheThings();
}
catch(e) {
console.error(e);
reportError(e);
}
}
View compete the average
function average(numbers) {
var total = numbers[0];
for (var i=1; i < numbers.length; i++){
total += numbers[i];
}
return total/numbers.length;
}
View In your own words
What is scope? Your explanation should include the idea of global vs. local scope.
A. Scope is the declaration and accesibility that is possible in javascript, i.e the local and global scope wherin the variables
get stored in a global way, that can accessed anywhere in the program or
a Local variables have ,They can only be accessed within the function.
Why are global variables avoided?
Global variables are avoided because it creates a fuss if we programming 1000s of lines of codes.
Explain JavaScript's strict mode?
Strick mode is a way of writing secure javascript. It helps us in avoiding globad variables. It will throw an error if the
View deleting keys
function keyDeleter(obj) {
obj.delete='foo';
obj.delete='bar';
return obj;
}
var sampleObj = {
foo: 'foo',
bar: 'bar',
View data merge
function mergeDataStreams(stream1, stream2) {
var results = {};
for (var i=0; i < stream1.length; i++) {
results[stream1[i].id] = stream1[i];
}
for (var key in results) {
var otherData = stream2.find(
function(item) { return item.id === key; });
for (var _key in otherData) {
View cat carousel
View flutter_in_app_purchase.dart
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:io';
import 'package:flutter/services.dart';
import 'package:flutter_inapp_purchase/flutter_inapp_purchase.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:ielts/screens/home_screen.dart';
import 'package:ielts/utils/app_constants.dart';
View in_app_purchase.dart
List<Widget> _button() {
List<Widget> widgets = this
._items
.map((item) => Container(
margin: EdgeInsets.symmetric(vertical: 10.0),
child: Container(
child: Column(
children: <Widget>[
Align(
alignment: Alignment.bottomCenter,