IPB





Welcome Guest ( Log In | Register )

> Need some help from Javascript and SQL peeps, I have an assesment test I have been working on
fido77
post Oct 31 2021, 10:08 PM
Post #1


Knight Lieutenant
********

Group: Clan Members
Posts: 989
Thank(s): 1
Points: 215
Joined: 5-June 08
From: Tyler, Texas, US
Member No.: 124




I have this assessment test I have been working on for my job. I don't mess with JavaScript or SQL very often, but they want me to finish it anyway :/
Was wondering if anyone here, like my good buddy Monkeyfiend, has any experience with it. I'm more of an OOP C# programmer. It looks simple enough, but I'm stuck on the second set of JavaScript questions and the second two SQL questions. I put answers, but I want to be sure they are correct before sending it back Monday morning. I'll just post them here for anyone who wants to give it a shot. Very much appreciated for any assistance.

//JavaScript

let data = ["A","B","C"];
let results = ["1","2","3"];
let entity = {};
for(let i = 0; i < data.length; i++){
entity[data[i]] = results[i];
}
console.log(entity);
Question: What do you expect the console.log will output?
--------------------------------------------------------------------------------------------
let fs = require('fs');

function read() {
var promise = new Promise(function(resolve, reject) {
fs.readFile("myFile.txt", "utf8", (err, data) => {

if (!err) {
resolve(data);
}
else {
reject(err);
}
});
});
return promise;
}


Question: Use the read function and output the results.
read().then((x) => {console.log(x)}).catch((err) => console.log(err) );
----------------------------------------------------------------------------
async / await option
try{
const x = await read();
console.log(x);
}catch(err){
console.log(err);
}
-------------------------------------------------------------------------------
function getText(text){
return new Promise(function(resolve, reject){
setTimeout(function(){
if(text)
resolve(text);
else
reject(new Error("text is empty"))
}, Math.random() * 10);
});
}
function logData(data){
console.log(data);
}

getText("Hello").then(logData);
getText("World").then(logData);

Question: Sometimes this app produces “Hello World” sometimes it produces “World Hello”. Explain why and correct it.
----------------------------------------------------------------------------------------------------------------------------------------

function data (){
return [1,2];
}

let [x,y] = data();

console.log(x);
console.log(y);
Question: What will console log out in this program and why?
________________________________________
_______________

SQL Technical Screening

Books
Id (int)
Title (text)
Price (int)
Authors
Id (int)
Name (text)
BookAuthors
BookId (int)
AuthorId (int)

WRITE A SELECT STATEMENT SHOWING ALL THE BOOKS ORDERED BY TITLE IN ASCENDING ORDER

WRITE A SELECT STATEMENT SHOWING ALL THE BOOKS AND THE BOOK'S RELATED AUTHOR(S)

WRITE A SELECT STATEMENT SHOWING THE AVERAGE COST OF A BOOK BY AUTHOR




--------------------

Go to the top of the page
 
+Quote Post

Posts in this topic


Reply to this topicStart new topic

 



RSS Lo-Fi Version Time is now: 16th November 2024 - 09:36 AM
Sneaky Monkeys Clan :: MonkeyFiend.com