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
const express = require('express') | |
const app = express() | |
const uploadRouter = require('./upload.route') | |
app.use(uploadRouter) | |
app.listen(3000, () => { | |
console.log('Server is running on port 3000') | |
}) |
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
// components/FileUpload.js | |
import React, { useState } from 'react'; | |
import axios from 'axios'; | |
const FileUpload = () => { | |
const [selectedFile, setSelectedFile] = useState(null); | |
const handleFileChange = (event) => { | |
setSelectedFile(event.target.files[0]); | |
}; |
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
// This stores the token in your local storage | |
const setAuthToken = (token) => { | |
localStorage.setItem('token', token) | |
} | |
// This extracts the token from your local storage | |
const getAuthToken = () => { | |
return localStorage.getItem('token') | |
} |
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
// Question 1: Create a function that will convert Fahrenheit to Celsius | |
function fahrenheitToCelsius( valueInFarenheit ) { | |
let valueInCelsius = (5 / 9) * (valueInFarenheit - 32); | |
return valueInCelsius; | |
} | |
// Question 1: Test cases | |
console.log(fahrenheitToCelsius(32) + "C"); // Output: 0C |
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
"use strict" | |
const prompt = require("prompt-sync")({sigint: true}) | |
// This RegEx tests for a Visa card that starts with 4 and has a total card number of 16 digits ONLY. Please run the code & reply the prompt with a random 16 digit card number that starts with 4 and has no spaces between the digits. | |
const auth = /^4\d{12,15}$/ | |
// Function to validate the Visa credit card number. | |
const validate = (cardNumber) => { | |
cardNumber = parseFloat(prompt('Please input your 13 - 16 digits Visa Card number: ')) | |
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 nth_most_rate_signature(list, n) { | |
list.sort(); | |
let min_count = n+1, res = -1; | |
let curr_count = 1; | |
for (let i = 1; i < n; i++) { | |
// eslint-disable-next-line eqeqeq | |
if (list[i] == list[i - 1]) | |
curr_count++; |