hi,
using hashtable how to find which number is ocurring how many times for example in 33767999we need to 3 has occurred 2 times, 7 two times and 9 three times
@texirv0203 - it was to convert a value that is a number to a string, then split it. That gives you access to an array of the individual digits.
var num = 33767999;
num.toString().split('').forEach(
// you write a function here
);
the function within the .forEach()
method would be able to access the individual elements of the array, and build the hash in an object.
.split()
and use a for
loop to access the elements. I'm not sure what your level of exposure is to various code functions in JavaScript.
@texirv0203 - in this context, I would say that you need to make this "hash" as an object. Each key/value pair in the object will be a key consisting of one of the digit values in the string, and the value would be the number of times that it occurs in the number. So you would want to end up with an object, for your example digit string, that looks like this:
{3: 2, 6: 1, 7: 2, 9: 3}
3: 2
6: 1
7: 2
9: 3
Are you familiar with creating objects in javascript?
n = int(input("Enter a positive integer to retrieve all the values of the Fibonacci series that correspond to this input : "))
def fib(n) :
v1 = 0
v2 = 1
while n > 0 :
for i in range(n):
v1,v2 = v2,v1+v2
print(v1, v2)
n-=1
fib(n)
sudo install learnyounode -g
in the cloud9 terminal in my blank workspace and it doesnt work :/
npm install learnyounode -g
I think @TylerDelRosario
module.js:471
throw err;
@texirv0203 - these are some basics about how to make an object that you need to use for this hash / number counter.
var myObj = {}; // initialize an empty object
var anyNum = 8;
myObj[anyNum] = 1; // after this, the object should have an entry with a key of "8", value of "1"
myObj[anyNum]++; // after this, the object should have an entry with a key of "8", value of "2"
anyNum = 5;
myObj[anyNum] = 1; // after this, the object should still have the entry for "8" and a new entry with a key of "5", value of "1"
myObj[anyNum]++; // after this, the object should have an entry with a key of "5", value of "2"
if you take that code and experiment with it, for example in a browser devtools console, you can see what's happening. Or you can go to http://pythontutor.com/javascript.html and plug it in, and run it.
I have some questions but one question at a time.
In my CSS, the .navbar-brand img connects to my logo in the top left corner of my bootstrap navbar. Its off center in that corner. Does anyone know how to position the logo correctly? Let me know. Thanks
@rodchsm
.navbar-brand img {
height: 50px;
margin-top: -15px;
}
Try this. Because there is a lot of padding in actual image I had to use a negative margin.
<html>
, <head>
code into the proper places in the CodePen interface. Then it works...
rodchsm sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3496 | @khaduch |http://www.freecodecamp.com/khaduch
<head>
section, but then the HTML section will be inserted into the output HTML code and probably conflict with your custom settings. By putting the external CSS in the CSS config panel, things get loaded in the proper order. You might be able to see what is going on if you load your page as it is now, and do a "View Frame Source" for the output panel.
rodchsm sends brownie points to @khaduch and @edwin0258 :sparkles: :thumbsup: :sparkles:
:cookie: 812 | @edwin0258 |http://www.freecodecamp.com/edwin0258
@rodchsm - some of the settings for the old site for that top section, the selector
.slideshow div.featured_holder {
background-color: rgba(0, 0, 0, 0.3);
background: url("//cache1.bigcartel.com/theme_assets/91/1.4.10/images/overlay_pattern.png");
background-repeat: repeat;
background-size: 4px;
height: 100%;
position: absolute;
top: 0;
width: 100%;
z-index: 100;
}
Has the height and width settings set to 100%, so it fills the screen.
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
h2 {
font-family: Lobster, Monospace;
}
.thick-green-border {
border-color: green;
border-width: 10px;
border-style: solid;
border-radius: 50%;
}
</style>
<div class="row">
<div class="col-xs-8">
<h2 class="text-primary text-center">CatPhotoApp</h2>
<div class="col-xs-4"><a href="#"><img class="img-responsive thick-green-border" src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back. "></a>
</div>
</div>
<img src="https://bit.ly/fcc-running-cats" class="img-responsive" alt="Three kittens running towards the camera. ">
<div class="row">
<div class="col-xs-4">
<button class="btn btn-block btn-primary">Like</button>
</div>
<div class="col-xs-4">
<button class="btn btn-block btn-info">Info</button>
</div>
<div class="col-xs-4">
<button class="btn btn-block btn-danger">Delete</button>
</div>
</div>
<p>Things cats <span class="text-danger">love:</span></p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
<form action="/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor"> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label>
<label><input type="checkbox" name="personality"> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Crazy</label>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</div>
rdavidson3 sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 389 | @padunk |http://www.freecodecamp.com/padunk
rdavidson3 sends brownie points to @padunk and @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3497 | @khaduch |http://www.freecodecamp.com/khaduch
html = html + .....
seahchye sends brownie points to @sorinr :sparkles: :thumbsup: :sparkles:
:star2: 1354 | @sorinr |http://www.freecodecamp.com/sorinr
Does anyone know how to change my bootstrap .navbar into a different color? #1c7089
navbar-inverse
class and put your backgound color
@rodchsm or you may add this to css:
nav.navbar-inverse{
background-color: #1c7089;
}
to override the default BS bg color
col-md-xx
to work properly in BS you need a parent element with class row
. I also recommend you to change the content to english. i'm sure you will find info in English about Alexander Nicolaevich on wikipedia
<ul class=" col-md-10 col-md-offset-1">
to give more spread width to the text
jheebz sends brownie points to @sorinr :sparkles: :thumbsup: :sparkles:
:star2: 1355 | @sorinr |http://www.freecodecamp.com/sorinr
primuscovenant sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 2056 | @heroiczero |http://www.freecodecamp.com/heroiczero
var colors = ['white', 'orange', 'blue'];
var color = colors[Math.floor(Math.random()*colors.length)];
console.log(color);
something like that and u dont need isColor variable
leet-hacks sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 390 | @padunk |http://www.freecodecamp.com/padunk
alessiochiffi sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 391 | @padunk |http://www.freecodecamp.com/padunk
if (isColor) {
// set color to white
} else {
// color is colors[colorIndex]
colorIndex = (colorIndex + 1) % color.length
}
isColor = !isColor;
src
ryan-ed sends brownie points to @jtan3 :sparkles: :thumbsup: :sparkles:
:cookie: 463 | @jtan3 |http://www.freecodecamp.com/jtan3
i
in the for loop - a global index into your colors
Hey folks, I get this error in my react application:
POST http://localhost:4000/graphql 500 (Internal Server Error)
HTTPFetchNetworkInterface.fetchFromRemoteEndpoint @ apollo.umd.js:520
(anonymous) @ apollo.umd.js:535
This is my networkInterface:
const networkInterface = createNetworkInterface({
uri: "http://localhost:4000/graphql",
opts: {
credentials: "same-origin",
mode: "no-cors" //remove this for production => Security!
}
});
Did I declare something wrong? Without the anti cors option, I get an cross-server-error.
target="_blank"
to the link so that they work properly when being clicked on
imonboss sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3499 | @khaduch |http://www.freecodecamp.com/khaduch
success: function (data) { ... }
— you could create an array to hold the results of data.query.pages
and then use the length of that array to create a loop which creates the right number of paragraphs, each with one of the results.
I have the following :
"Create a view consisting of a list of battles. The list should be:
-filterable by attacker and /or defender country;
-searchable by country (eg. I search for italy, the list should display only battle with italy as defender or attacker)
UI/UX bonus points!
API: www.exampleee.com/en/etc
<H1 class="text-center"> Nikola Tesla</H1>
<div class="container">
<div class="col-sm-5" >
<img class="img-responsive center-block" src= "http://cdn.wonderfulengineering.com/wp-content/uploads/2016/03/Tesla-compulsions-and-thinking3.jpg">
</div>
</div>
<div class="text-center">The Master of Electricity</div>
rdavidson3 sends brownie points to @maxv and @sarkioja :sparkles: :thumbsup: :sparkles:
:cookie: 113 | @sarkioja |http://www.freecodecamp.com/sarkioja
@leanjunio Additionally, props are meant more to inform the component on how to behave, whereas state has to do more with, well, the state of the application, ie things are likely to change as the user interacts with them.
A basic example of how props would be used where state is not would be if you create a button component that could be any color. Maybe you pass the color as a prop when creating a form. Not a great example but hopefully you get the idea :+1: