Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 88 additions & 3 deletions week-1-project/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,127 @@ const object = {
NaNyStrings: [],
isNumberyString: function (param) {
// write me!
if (typeof param=== "string" && isNaN(param)=== false ){
return true;
}else{
return false;
}
},
addString: function (param) {
if (null) return false; // write this early return condition

if (typeof param !== 'string') return false; // write this early return condition
else {
if (isNaN(param)) {
this.NaNyStrings.push(param);
} else {
this.numberyStrings.push(param);
}
return true;
}

// write me! (using this.isNumberyString)
},
allStrings: function () {
// write me!
if( this.numberyStrings.length !== 0 && this.NaNyStrings.length === 0){
return this.numberyStrings;
}else if ( this.numberyStrings.length === 0 && this.NaNyStrings.length !== 0){
return this.NaNyStrings;
}else if(this.numberyStrings.lenght !== 0 && this.NaNyStrings.lenght !== 0){

return this.numberyStrings.concat(this.NaNyStrings);

}
},
evenStrings: function () {
// write me!
function notOddNumber(number){
return number %2 === 0;
}
if(this.NaNyStrings.length !== 0 && this.numberyStrings.length === 0){
return this.numberyStrings;
}else if (this.NaNyStrings.length === 0 && this.numberyStrings.length !== 0 ){
return this.numberyStrings.filter(notOddNumber);// take the even numbers
}else if(this.NaNyStrings.length !== 0 && this.numberyStrings.length !== 0){
return this.numberyStrings.filter(notOddNumber);
}

},

oddStrings: function () {
// write me!
function notEvenNumber(number){
return number %2 !== 0;
}
if(this.NaNyStrings.length !== 0 && this.numberyStrings.length === 0){
return this.numberyStrings;
}else if (this.NaNyStrings.length === 0 && this.numberyStrings.lenght !== 0) {
return this.numberyStrings.filter(notEvenNumber);// take the odd numbers
}else if(this.NaNyStrings.length !== 0 && this.numberyStrings.length !== 0){
return this.numberyStrings.filter(notEvenNumber);
}
},

negativeStrings: function () {
// write me!
function negatifNumbers(number){
return number <0;
}
if(this.NaNyStrings.length !== 0 && this.numberyStrings.length === 0){
return this.numberyStrings;
}else if( this.NaNyStrings.length === 0 ){ //&& this.numberyStrings.length !== 0
return this.numberyStrings.filter(negatifNumbers);
}else if (this.NaNyStrings.length !== 0 && this.numberyStrings.length !== 0);
return this.numberyStrings.filter(negatifNumbers);
},


positiveStrings: function () {
// write me!
function pozitifNumbers(number){
return number > 0 || number === "";
}
if(this.NaNyStrings.length !== 0 && this.numberyStrings.length === 0){
return this.numberyStrings;
}else if( this.NaNyStrings.length === 0 ){ //&& this.numberyStrings.length !== 0
return this.numberyStrings.filter(pozitifNumbers);
}else if( this.NaNyStrings.length !== 0 && this.numberyStrings.length!==0 ){
return this.numberyStrings.filter(pozitifNumbers);
}else if( this.NaNyStrings.length !== 0 && this.numberyStrings.length!==0){
return this.numberyStrings.filter(pozitifNumbers);
}
},
zeroStrings: function () {
// write me!
function sifir(number){
return number == 0 || number ==" ";
}
if(this.NaNyStrings.length !== 0 && this.numberyStrings.length === 0){
return this.numberyStrings;
}else if( this.NaNyStrings.length === 0 && this.numberyStrings.length !== 0){
return this.numberyStrings.filter(sifir);
}else if (this.NaNyStrings.length !== 0 && this.numberyStrings.length !== 0){
return this.numberyStrings.filter(sifir);
}

},
numberyAsNumbers: function () {
// write me!


},
NaNyAsNumbers: function () {
// write me!
},
sumOfNumbery: function () {
// write me!
function sum(a,b) {
return (a+b);

}
},
sumOfNaNy: function () {
// write me!
return undefined;
},
};


45 changes: 29 additions & 16 deletions week-2-project/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,69 +15,82 @@ const object = {
entries: {},
isPrimitive: function (value) {
// write me!
//if (typeof Object(value) === 'object') return true;
//return (value !== Object(value));
var type = typeof value;
return value == null || (type != "object" && type != "function");
},
hasKey: function (obj, key) {
// write me!
return obj != null && hasOwnProperty.call(obj, key);
},
hasValue: function (obj, value) {
// write me!
return (Object.values(obj).indexOf(value)> -1);
},
addEntry: function (key, value) {
if (null) { // write me!
if (key='string') { // write me!
return new TypeError('addEntry: key should be a string');
}
if (null) { // write me! (using this.isPrimitive)
if (value !== Object(value)!== true) { // write me! (using this.isPrimitive)
this.primitive=[];
return new TypeError('addEntry: value should be a primitive');
}
if (null) { // write me! (using this.hasKey)
if (this.entries[key]=value) { // write me! (using this.hasKey)

return new Error(`addEntry: key "${key}" already exists`);
}

// write me!

},
removeEntry: function (key) {
if (null) { // write me!
if (key!=="string") { // write me!
return new TypeError('removeEntry: key should be a string');
}
if (null) { // write me! (using this.hasKey)

if (this.hasOwnProperty(key)===true) { // write me! (using this.hasKey)// hasKey ile bilinmesi gereken hasOwnProperty
return new ReferenceError(`removeEntry: no property "${key}" in this.entries`);
}
}else
return true; //BURAYA TEKRAR DON!!!!!

// write me!
},
updateEntry: function (key, value) {
if (null) { // write me!
if (key="string") { // write me!
return new TypeError('updateEntry: key should be a string');
}
if (null) { // write me! (using this.isPrimitive)
if (this.isPrimitive(value =='', arg)) { // write me! (using this.isPrimitive)
return new TypeError('updateEntry: value should be a primitive');
}
if (null) { // write me! (using this.hasKey)
if (this.hasKey(key!==key)) { // write me! (using this.hasKey)
return new ReferenceError(`updateEntry: no property "${key}" in this.entries`);
}

// write me!
},
readAll: function () {
// write me!
},

},

findByKey: function (key) {
if (null) { // write me!
if (key !== 'string') { // write me!
return new TypeError('findByKey: key should be a string');
}
if (null) { // write me! (using this.hasKey)
if (this.hasKey === "string") { // write me! (using this.hasKey)
return new ReferenceError(`findByKey: no property "${key}" in this.entries`);
}

//BURAYA TEKRAR DON
// write me!
},
findByValue: function (value) {
if (null) { // write me! (using this.isPrimitive)
if (value !== 'isPrimitive') { // write me! (using this.isPrimitive)
return new TypeError('findByValue: value should be a primitive');
}
if (null) { // write me! (using this.hasValue)
if (this.hasValue(value)) { // write me! (using this.hasValue)
return new ReferenceError(`findByValue: no entry with value (${typeof value}, ${value})`);
}
}else return false; //BURAYA TEKRAR DON

// write me! (this one is a bit trickier)
},
Expand Down
4 changes: 2 additions & 2 deletions week-2-project/practice-problems/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

<!-- why won't local parser-babylon work -->
<script src="../../dependencies/prettier/standalone.js"></script>
<!-- <script src="https://unpkg.com/prettier@1.13.0/standalone.js"></script> -->
<!-- <script src="../dependencies/prettier/parser-babylon.js"></script> -->
<script src="https://unpkg.com/prettier@1.13.0/standalone.js"></script>
<script src="../dependencies/prettier/parser-babylon.js"></script>
<script src="https://unpkg.com/prettier@1.13.0/parser-babylon.js"></script>

<script src="../../dependencies/evaluate.js"></script>
Expand Down
15 changes: 14 additions & 1 deletion week-2-project/practice-problems/objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,32 +116,44 @@ try {
function passTheAssertions1() {
; // declare and assign a1
; // declare and assign a2
const a1={}
const a2= a1
//burada yazdigin altta istenen esitli ya da esitsiz olan haller, a1 ile a2 birbirine esit

console.assert(a1 === a2, 'a1 should strictly equal a2');

; // declare and assign b1
; // declare and assign b2
const b1={}
const b2={}// burada yazdigin seyler altta istenen esitlik ya da esitsizlikler
console.assert(b1 !== b2, 'b1 should not strictly equal b2');

// ---

; // write one line to pass the assertions
a1.x === 'hi';
console.assert(a1.x === a2.x, 'a1.x should strictly equal a2.x');
console.assert(a1.x === 'hi!', 'a1.x should strictly equal "hi!"');

; // write two lines to pass the assertions
;
b1.x=== 'bye!';
b2.x==='bye!';
console.assert(b1.x === b2.x, 'b1.x should strictly equal b2.x');
console.assert(b1.x === 'bye!', 'b1.x should strictly equal "bye!"');

// --
const index = 'y';

a2[index]==='roof!';
a2[index]===a1[index];
; // write one line to pass the assertions
console.assert(a1[index] === a2[index], 'a1[index] should strictly equal a2[index]');
console.assert(a1[index] === 'roof!', 'a1[index] should strictly equal "roof!"');

; // write two lines to pass the assertions
;
b2[index] === b1[index];
b1[index]==='floor!';
console.assert(b1[index] === b2[index], 'b1[index] should strictly equal b2[index]');
console.assert(b1[index] === 'floor!', 'b1[index] should strictly equal "floor!"');

Expand All @@ -153,6 +165,7 @@ try {
function passTheAssertions2() {
const value1 = 5;
let reference1 = {};


; // write this line
console.assert(value2 === value1, "value1 should strictly equal value2");
Expand Down
15 changes: 13 additions & 2 deletions week-2-project/practice-problems/project-prep.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ try {
];
function isPrimitive(thing) {
// write me!
var type = typeof thing;
return thing == null || (type != "object" && type != "function");
}
isPrimitive.display = true;
evaluate(isPrimitive, isPrimitiveTests);
Expand All @@ -38,13 +40,16 @@ try {
];
function hasKey(obj, key) {
// write me!
}
return obj != null && hasOwnProperty.call(obj, key);
// return (Object.values(obj).indexOf(values) > -1);
}

hasKey.display = true;
evaluate(hasKey, hasKeyTests);


const hasValueTests = [
{ name: 'first', args: [{ a: 0 }, 0], expected: true },
{ name: 'first', args: [{ a:/*key*/ 0/* value*/ }, 0], expected: true },
{ name: 'second', args: [{ b: 0 }, 1], expected: false },
{ name: 'third', args: [{ a: 1 }, 0], expected: false },
{ name: 'fourth', args: [{ b: 1 }, 1], expected: true },
Expand All @@ -55,6 +60,8 @@ try {
function hasValue(obj, value) {
// write me!
// consider using Object.keys, .filter and obj.hasOwnProperty

return (Object.values(obj).indexOf(value)> -1);
}
hasValue.display = true;
evaluate(hasValue, hasValueTests);
Expand Down Expand Up @@ -88,6 +95,9 @@ try {
function deleteFromObject(obj, key) {
// write me!
// (remember to avoid side effects)


delete deleteFromObject(obj);
}
deleteFromObject.display = true;
evaluate(deleteFromObject, deleteFromObjectTests)
Expand All @@ -104,6 +114,7 @@ try {
function findByKey(obj, key) {
// write me!
// (remember to avoid side effects)

}
findByKey.display = true;
evaluate(findByKey, findByKeyTests)
Expand Down