This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Person(firstandlast) { | |
var full = firstandlast; | |
var first = firstandlast.split(' ')[0]; | |
var last = firstandlast.split(' ')[1]; | |
this.getFirstName = function(){return first;}; | |
this.getLastName = function(){return last;}; | |
this.getFullName = function(){return first + ' ' + last;}; | |
this.setFirstName = function(newFirstName){first = newFirstName;}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function updateInventory(arr1, arr2) { | |
var cart = arr1.concat(arr2); | |
var sum = []; | |
var dif = []; | |
for (var i = 0; i < arr1.length; i++) { | |
for (var j = 0; j < arr2.length; j++) { | |
if (arr1[i][1] == arr2[j][1]) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arr = [ [ 'TWENTY', 20 ], | |
[ 'TWENTY', 20 ], | |
[ 'TWENTY', 20 ], | |
[ 'TEN', 10 ], | |
[ 'TEN', 10 ], | |
[ 'FIVE', 5 ], | |
[ 'FIVE', 5 ], | |
[ 'FIVE', 5 ], | |
[ 'ONE', 1 ], | |
[ 'QUARTER', 0.25 ], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function permAlone(str) { | |
var arr = str.split(''); var perm = []; var ar; | |
function swap(i, j) { | |
ar = arr[i]; | |
arr[i] = arr[j]; | |
arr[j] = ar; | |
} | |
function generate(e) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//client side | |
var socket = io.connect('http://localhost:3000'); | |
var room = "abc123"; | |
socket.on('connect', function() { | |
$('button').click(function() { | |
socket.emit('room', room); | |
}) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import io from 'socket.io-client' | |
const socket = io() | |
class App extends React.Component { | |
constructor() { | |
super(); | |
this.state = {messages: [], value: ''} | |
this.handle = this.handle.bind(this) | |
this.submit = this.submit.bind(this) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstring> | |
#define _CRT_SECURE_NO_WARNINGS | |
using namespace std; | |
class Sir | |
{ | |
private: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <random> | |
int generator() { | |
using namespace std; | |
std::random_device rd; // obtain a random number from hardware | |
std::mt19937 random(rd()); // seed the generator | |
std::uniform_int_distribution<> range(1, 100); // | |
return range(random); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
void bubble(int* arr, int length) { | |
int c{}; | |
for (int i = 0; i < length - 1; i++) { | |
if (arr[i] > arr[i+1]) { | |
arr[i] = arr[i]*arr[i+1]; | |
arr[i+1] = arr[i] / arr[i+1]; | |
arr[i]= arr[i] / arr[i+1]; | |
c++; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
void printBinary(int x) | |
{ | |
// Termination case | |
if (x <= 0) | |
return; | |
// Recurse to the next bit | |
printBinary(x / 2); |
OlderNewer