Skip to content

Commit

Permalink
Write JS Code for getting weather condition #180
Browse files Browse the repository at this point in the history
  • Loading branch information
RohanMalik2710 committed Mar 8, 2023
1 parent 0d47af5 commit eb78f15
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 0 deletions.
41 changes: 41 additions & 0 deletions dsa/convertSortedArrayToBinarySearchTree.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include <iostream>
using namespace std;

struct TreeNode {

int data;
TreeNode *left, *right;

TreeNode(int val) {

data = val;
left = nullptr;
right = nullptr;
}
};

TreeNode* constructTreeFromArray(int nums[], int start, int end) {

if (start > end) {

return nullptr;
}

int mid = start + (end - start) / 2;
TreeNode* node = new TreeNode(nums[mid]);

node->left = constructTreeFromArray(nums, start, mid - 1);
node->right = constructTreeFromArray(nums, mid + 1, end);

return node;
}

TreeNode* sortedArrayToBST(int nums[], int size) {

if (size == 0) {

return nullptr;
}

return constructTreeFromArray(nums, 0, size - 1);
}
29 changes: 29 additions & 0 deletions dsa/issue156.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <iostream>
#include <cmath>
using namespace std;

int main(){
int n;
cin >> n;

int x;
x = floor(n/2);
if(n%2 == 1){
if(x%2==1){
cout << '0' << endl;
}
else{
cout<<'1'<<endl;
}

}
else{
if(x%2==0){
cout << '0' << endl;
}
else{
cout<<'1'<<endl;
}
}

}
7 changes: 7 additions & 0 deletions web/APIcallUsingJavaScript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fetch('https://pokeapi.co/api/v2/pokemon/pikachu')
.then(res => res.json())
.then(data => {
console.log('name: ' + data.name);
console.log('pokemon type: ' + data.types.map(type => type.type.name));
console.log('abilities: ' + data.abilities.map(ability => ability.ability.name).join(', '));
});
14 changes: 14 additions & 0 deletions web/dice roll.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<html>
<head>
<script>
function rollDice() {
var dice1 = Math.floor(Math.random() * 6) + 1;
alert("You rolled : " + dice1);
}
</script>
</head>
<body>
<h1>Dice Roll</h1>
<button onclick="rollDice()">Roll Dice</button>
</body>
</html>

0 comments on commit eb78f15

Please sign in to comment.