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 twoSum(nums, target) { | |
// Create a map to store each number and its index | |
const numMap = new Map(); | |
// Iterate through the array | |
for (let i = 0; i < nums.length; i++) { | |
const complement = target - nums[i]; | |
// Check if the complement exists in the map | |
if (numMap.has(complement)) { |
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
The order of items in the displayed list will be: | |
ford | |
honda | |
toyota | |
vw | |
bmw | |
mercedes | |
Explanation: | |
Initial Order: |
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
The computeTotal function has a couple of issues: | |
Arrow Function and this Context: | |
Issue: Arrow functions do not bind their own this value, so this inside the each callback refers to the outer this (which is the global object in this case) instead of the current DOM element. | |
Solution: Use a regular function expression to correctly bind this. | |
Parsing Errors: | |
Issue: The parseInt function might fail silently if the text content cannot be converted to a number. | |
Solution: Ensure that the text content is a valid number before adding it to the total. |
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
Positive Aspects: | |
Functionality: | |
The function correctly builds a sentence and updates the h1 element with the new text. | |
The use of console logs helps in tracing the flow and state of the function. | |
Suggestions for Improvement: | |
Variable Declarations: | |
Current Issue: Variables are declared without var, let, or const. | |
Suggestion: Always declare variables using let or const to avoid polluting the global scope. | |
javascript |
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
<?php | |
class Basket { | |
private $catalogue; | |
private $deliveryRules; | |
private $offers; | |
private $basket; | |
public function __construct($catalogue, $deliveryRules, $offers) { | |
$this->catalogue = $catalogue; |
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
// https://gist.github.com/Esgrima/c0d4bff4b0d3909daf8994410cd659ce | |
// https://dartpad.dev/c0d4bff4b0d3909daf8994410cd659ce | |
import 'package:flutter/material.dart'; | |
import 'package:flutter_test/flutter_test.dart'; | |
import 'package:boolean_selector/boolean_selector.dart'; | |
// (TODO: Tip # 1) Consider making frequently used variables/values constants | |
const _fooConst1 = ''; | |
const _fooConst2 = ''; |
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 { useLocation } from "react-router-dom"; | |
export function useQueryParams() { | |
const query = new URLSearchParams(useLocation().search); | |
return query; | |
} |
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
// | |
// RemoteImage.swift | |
// List | |
// | |
// Created by noda on 12/13/20. | |
// | |
import SwiftUI | |
struct RemoteImage: View { |
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 PropTypes from "prop-types"; | |
import DimensionConsumer from "./DimensionContext"; | |
import { getScreenWidth, getScreenHeight } from "./selectors"; | |
const ScreenConsumer = ({ children }) => { | |
return ( | |
<DimensionConsumer> | |
{dimensions => | |
children(getScreenWidth(dimensions), getScreenHeight(dimensions)) |
NewerOlder